Skip to content

Commit 38fce2e

Browse files
ibeltagyBorda
andauthored
fix selecting GPUs using CUDA_VISIBLE_DEVICES (#2739)
* fix #2407 * Update pytorch_lightning/trainer/distrib_data_parallel.py Co-authored-by: Jirka Borovec <[email protected]> Co-authored-by: Jirka Borovec <[email protected]>
1 parent 7da7d2e commit 38fce2e

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

pytorch_lightning/trainer/distrib_data_parallel.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -555,8 +555,7 @@ def ddp_train(self, process_idx, mp_queue, model, is_master=False, proc_offset=0
555555
gpu_idx = process_idx
556556
if is_master:
557557
# source of truth is cuda for gpu idx
558-
gpus = os.environ['CUDA_VISIBLE_DEVICES'].split(',')
559-
gpu_idx = int(gpus[self.local_rank])
558+
gpu_idx = self.local_rank
560559

561560
self.root_gpu = gpu_idx
562561
torch.cuda.set_device(self.root_gpu)

0 commit comments

Comments
 (0)