ml-agents icon indicating copy to clipboard operation
ml-agents copied to clipboard

Learn.py takes all GPU memory

Open r-lipton opened this issue 8 years ago • 6 comments

Hello,

When I run a training using learn.py, the process allocated all the memory of the GPU. Is there a way to avoid this, and make it takes only what it needs?

Thanks

r-lipton avatar Apr 11 '18 07:04 r-lipton

I dont think the problem is with tensorflow or the ml-agents (when i start training it uses about 20 mb vram)

You should check if your game is doing what you think it does. If you have some kind of memory leak you have to remember than the game is played 100 times as fast as normal, so that might amplify the problem.

Hengoo avatar Apr 11 '18 09:04 Hengoo

Hi @r-lipton, is this using one of our sample environments or your own? Generally, as @Hengoo and @MarcoMeter pointed out, we haven't noticed this on our environments.

mmattar avatar Apr 11 '18 17:04 mmattar

I have seen this problem with OpenAI.Baselines when invoking a 2nd training run. Setting gpu_options.allow_growth = True fixed it for me

replace trainer_controller.py line 212 with tf.Session(config=config) as sess: with:

    config = tf.ConfigProto()
    config.gpu_options.allow_growth = True
    with tf.Session(config=config) as sess:

Update: I tested this today and was able to run multiple training runs concurrently on a single GPU

Sohojoe avatar Apr 11 '18 22:04 Sohojoe

It's using my own created environment. The solution of @Sohojoe worked for me, thanks!

r-lipton avatar Apr 13 '18 12:04 r-lipton

Hi all. I've made a PR for this, and it will be added to the v0.5 release. https://github.com/Unity-Technologies/ml-agents/pull/1192

awjuliani avatar Sep 06 '18 20:09 awjuliani

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

lock[bot] avatar Jan 03 '20 02:01 lock[bot]