Hello,
I am having the same issue and the fix above does not work.
I think it is related to this: https://github.com/torch/cutorch/issues/677 163
When trying with CUDA_VISIBLE_DEVICES=1
not using set_device throw the runtime error,
then trying torch.cuda.set_devices(2) throws an ordinal error, I thought torch was counting from 1.
any help ?