Use CUDA_VISIBLE_DEVICES=0,1 python your_script.py to set all available GPU devices for all processes.
I’m not aware of the intrinsecs of torch.cuda.set_device.
Just to mention when you pass device_ids this is a list which enlist the available gpus from the pytorch pov.
For example, if you call
CUDA_VISIBLE_DEVICES=5,7,9 there will be 3 gpus from 0 to 2.
so you can pass device_ids=[0,1,2]