When I transfer my model to cuda:0:
model = model.to(device=torch.device("cuda:0"))
Everything is fine, but when I try to do the same for torch.device("cuda:1")
, I got:
RuntimeError: CUDA error (10): invalid device ordinal
What I tried:
- os.environ[“CUDA_VISIBLE_DEVICES”] = “1”
- export CUDA_VISIBLE_DEVICES=1 and then python my_program.py
- CUDA_VISIBLE_DEVICES=1 python my_program.py
However, I’d like to notice that print(torch.cuda.current_device())
give me 0 always.
Also, I use conda env. Can conda be a reason of issue?