Skip to content

Commit

Permalink
handle backend if already init
Browse files Browse the repository at this point in the history
  • Loading branch information
awaelchli committed Jun 28, 2021
1 parent 4c1b289 commit b055365
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pytorch_lightning/plugins/training_type/ddp.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ def post_dispatch(self) -> None:
def barrier(self, *args, **kwargs) -> None:
if not torch_distrib.is_initialized():
return
if _TORCH_GREATER_EQUAL_1_8 and self.torch_distributed_backend == "nccl":
if _TORCH_GREATER_EQUAL_1_8 and torch_distrib.dist_backend == "nccl":
torch_distrib.barrier(device_ids=self.determine_ddp_device_ids())
else:
torch_distrib.barrier()
Expand Down
3 changes: 1 addition & 2 deletions pytorch_lightning/plugins/training_type/ddp_spawn.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,8 +312,7 @@ def __recover_child_process_weights(self, best_path, last_path):
def barrier(self, *args, **kwargs) -> None:
if not torch_distrib.is_initialized():
return
if _TORCH_GREATER_EQUAL_1_8 and self.torch_distributed_backend == "nccl":
assert torch_distrib.dist_backend == "nccl"
if _TORCH_GREATER_EQUAL_1_8 and torch_distrib.dist_backend == "nccl":
torch_distrib.barrier(device_ids=self.determine_ddp_device_ids())
else:
torch_distrib.barrier()
Expand Down

0 comments on commit b055365

Please sign in to comment.