Great answer !!! It helps me a lot.
CUDA_VISIBLE_DEVICES=3 python test.py
and it doesn’t work for me.
export CUDA_VISIBLE_DEVICES=3 python test.py
does work for me.
The following works properly.
import os os.environ["CUDA_DEVICE_ORDER"]="PCI_BUS_ID" os.environ["CUDA_VISIBLE_DEVICES"]=<YOUR_GPU_NUMBER_HERE>
Usually GPU numbers start from 0. Since you have issue with the default device, try anything other that 0.
Thanks a lot for this solution!