Specify GPU for training but other GPU is allocated

Hi.

I specify a second GPU for training my model via DEVICE = torch.device("cuda:1" if torch.cuda.is_available() is True else "cpu") but the memory of the first GPU, which is cuda:0 is allocated. Can you please let me know what am I missing?

You are most likely creating the CUDA context on the default device and/or accidentally allocating additional memory on it.
Mask the device you would like to use via CUDA_VISIBLE_DEVICES=1 python script.py args and use cuda:0 in the script to select the masked device.

1 Like

Thank you for the immediate answer and for providing me the solution. However, I didn’t allocate it on the default device. If we assume that I didn’t make a mistake at all, what would be a possible option?

Did you solve the problem? If so, how to solve it?