two things you did wrong:
- there shouldn’t be semicolon. with the semicolon, they are on two different lines, and python won’t see it.
- even with the correct command
CUDA_VISIBLE_DEVICES=3 python test.py
, you won’t seetorch.cuda.current_device() = 3
, because it completely changes what devices pytorch can see. So in pytorch land device#0 is actually your device#3 of the system. You can verify that from nvidia-smi.