Skip to content

Commit a3ee912

Browse files
committed
Fix torchelastic detection with non-distributed installations (#13142)
* Fix torchelastic detection under Mac * CHANGELOG
1 parent 10d2ef9 commit a3ee912

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
1818
- Fixed the number of references of `LightningModule` so it can be deleted ([#12897](https://github.com/PyTorchLightning/pytorch-lightning/pull/12897))
1919
- Fixed `materialize_module` setting a module's child recursively ([#12870](https://github.com/PyTorchLightning/pytorch-lightning/pull/12870))
2020
- Fixed issue where the CLI could not pass a `Profiler` to the `Trainer` ([#13084](https://github.com/PyTorchLightning/pytorch-lightning/pull/13084))
21+
- Fixed torchelastic detection with non-distributed installations ([#13142](https://github.com/PyTorchLightning/pytorch-lightning/pull/13142))
2122

2223

2324
## [1.6.3] - 2022-05-03

pytorch_lightning/plugins/environments/torchelastic_environment.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ def main_port(self) -> int:
6262
def detect() -> bool:
6363
"""Returns ``True`` if the current process was launched using the torchelastic command."""
6464
if _TORCH_GREATER_EQUAL_1_9_1:
65-
return torch.distributed.is_torchelastic_launched()
65+
# if not available (for example on MacOS), `is_torchelastic_launched` is not defined
66+
return torch.distributed.is_available() and torch.distributed.is_torchelastic_launched()
6667
required_env_vars = {"RANK", "GROUP_RANK", "LOCAL_RANK", "LOCAL_WORLD_SIZE"}
6768
return required_env_vars.issubset(os.environ.keys())
6869

0 commit comments

Comments
 (0)