How to set a limit to gpu usage

Hi,
with tensorflow I can set a limit to gpu usage, so that I can use 50% of gpu and my co-workers (or myself on another notebook) can use 50%

I just have to do this:

config = tf.ConfigProto(gpu_options=tf.GPUOptions(per_process_gpu_memory_fraction=0.7))
sess = tf.InteractiveSession(config=config)

Do you know how to do this with pytorch ?

Thanks

3 Likes

there is no way to do this in pytorch. However, PyTorch doesn’t pre-occupy the GPU’s entire memory, so if your computation only uses 50% of GPU, only that much is locked by PyTorch

2 Likes

Is this still the case?

In case someone still stumbles upon this question: With PyTorch 1.8, there is set_per_process_memory_fraction

1 Like