Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix environment variable order for global rank determination #11406

Merged
merged 9 commits into from
Feb 17, 2022
3 changes: 2 additions & 1 deletion pytorch_lightning/utilities/distributed.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ def wrapped_fn(*args: Any, **kwargs: Any) -> Optional[Any]:

# TODO: this should be part of the cluster environment
def _get_rank() -> int:
rank_keys = ("RANK", "SLURM_PROCID", "LOCAL_RANK")
# SLURM_PROCID can be set even if Slurm is not managing the multiprocessing, therefore LOCAL_RANK needs to be checked first
rank_keys = ("RANK", "LOCAL_RANK", "SLURM_PROCID")
awaelchli marked this conversation as resolved.
Show resolved Hide resolved
awaelchli marked this conversation as resolved.
Show resolved Hide resolved
for key in rank_keys:
rank = os.environ.get(key)
if rank is not None:
Expand Down