Skip to content

Commit 6b0a84d

Browse files
committed
fix global rank
1 parent a0f80a6 commit 6b0a84d

File tree

3 files changed

+2
-4
lines changed

3 files changed

+2
-4
lines changed

pytorch_lightning/strategies/ddp.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,6 @@ def __init__(
114114
self._pids: Optional[List[int]] = None
115115
self._sync_dir: Optional[str] = None
116116
self._rank_0_has_called_call_children_scripts: bool = False
117-
self.set_world_ranks()
118117

119118
@property
120119
def is_distributed(self) -> bool:
@@ -132,7 +131,6 @@ def num_nodes(self) -> int:
132131
def num_nodes(self, num_nodes: int) -> None:
133132
# note that world ranks is related to num_nodes, when resetting it, need to reset world ranks
134133
self._num_nodes = num_nodes
135-
self.set_world_ranks()
136134

137135
@property
138136
def num_processes(self):

pytorch_lightning/strategies/ddp_spawn.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ def __init__(
8686
self._ddp_comm_hook = ddp_comm_hook
8787
self._ddp_comm_wrapper = ddp_comm_wrapper
8888
self._local_rank = 0
89-
self.set_world_ranks()
9089

9190
@property
9291
def num_nodes(self) -> int:
@@ -100,7 +99,6 @@ def num_processes(self):
10099
def num_nodes(self, num_nodes: int) -> None:
101100
# note that world ranks is related to num_nodes, when resetting it, need to reset world ranks
102101
self._num_nodes = num_nodes
103-
self.set_world_ranks()
104102

105103
@property
106104
def local_rank(self) -> int:

pytorch_lightning/trainer/connectors/accelerator_connector.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -683,6 +683,8 @@ def _lazy_init_strategy(self):
683683
self.strategy._num_nodes = self._num_nodes_flag
684684
if hasattr(self.strategy, "sync_batchnorm"):
685685
self.strategy.sync_batchnorm = self.sync_batchnorm
686+
if hasattr(self.strategy, "set_world_ranks"):
687+
self.strategy.set_world_ranks()
686688

687689
from pytorch_lightning.utilities import _IS_INTERACTIVE
688690

0 commit comments

Comments
 (0)