How to run code on 2 specific GPU

I have 3 GPU in my system.But I can’t use the first GPU (.cuda(0) ) since it is using for display purpose.and I cant also use nn.DataParallel() Since it is using all of 3 and I dont want to use 1st GPU.Also i tried .cuda([1,2]) which is not working.So i can only use .cuda(1) or .cuda(2)? Is there any way i can use only 2nd and 3rd GPU?
Thank you in Advance

You could mask your GPU0 using

import os
os.environ["CUDA_VISIBLE_DEVICES"]="1, 2"

This will make sure device with id 0 is not visible in this script.

3 Likes

If i am using that I am getting this error

That’s strange. Could you please check if images was moved to a GPU?