Skip to content

Commit f933d7a

Browse files
awaelchliBorda
authored andcommitted
fix display bug (#7395)
(cherry picked from commit 6bc616d)
1 parent 85b71c8 commit f933d7a

File tree

1 file changed

+3
-3
lines changed
  • pytorch_lightning/accelerators

1 file changed

+3
-3
lines changed

pytorch_lightning/accelerators/gpu.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def setup(self, trainer: 'pl.Trainer', model: 'pl.LightningModule') -> None:
3636
"""
3737
if "cuda" not in str(self.root_device):
3838
raise MisconfigurationException(f"Device should be GPU, got {self.root_device} instead")
39-
self.set_nvidia_flags()
39+
self.set_nvidia_flags(trainer.local_rank)
4040
torch.cuda.set_device(self.root_device)
4141
return super().setup(trainer, model)
4242

@@ -55,12 +55,12 @@ def teardown(self) -> None:
5555
torch.cuda.empty_cache()
5656

5757
@staticmethod
58-
def set_nvidia_flags() -> None:
58+
def set_nvidia_flags(local_rank: int) -> None:
5959
# set the correct cuda visible devices (using pci order)
6060
os.environ["CUDA_DEVICE_ORDER"] = "PCI_BUS_ID"
6161
all_gpu_ids = ",".join([str(x) for x in range(torch.cuda.device_count())])
6262
devices = os.getenv("CUDA_VISIBLE_DEVICES", all_gpu_ids)
63-
_log.info(f"LOCAL_RANK: {os.getenv('LOCAL_RANK', 0)} - CUDA_VISIBLE_DEVICES: [{devices}]")
63+
_log.info(f"LOCAL_RANK: {local_rank} - CUDA_VISIBLE_DEVICES: [{devices}]")
6464

6565
def to_device(self, batch: Any) -> Any:
6666
# no need to transfer batch to device in DP mode

0 commit comments

Comments
 (0)