Why multiple GPU are getting used even though I choose one from terminal?

Viewed 20

I have a server access which has multiple GPUs that can be accessed simultaneously by many users. I choose only 1 gpu_id from the terminal and have a code like this.

device = "cuda:"+str(FLAGS.gpu_id) if torch.cuda.is_available() else "cpu"

where FLAGS is a parser, parsing arguments from terminal.

Even though I select only one id, I saw that I am using 2 different GPUs. That causes issues, when the other GPU memory is almost full, and my process terminates by throwing "CUDA out of memory" error.

I want to understand, what could be the possible cases for such thing to happen?

1 Answers

It is hard to tell what is wrong without knowing how you use the device parameter. In any case, you can try to achieve what you want with a different approach. Run your python script in the following way:

CUDA_VISIBLE_DEVICES=0 python3 my_code.py
Related