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 LOCAL_RANK to be RANK in if_main_process #2506

Merged
merged 10 commits into from
Apr 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions speechbrain/utils/distributed.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* Abdel Heba 2020
* Aku Rouhe 2020
* Peter Plantinga 2023
* Adel Moumen 2024
"""

import datetime
Expand All @@ -12,7 +13,7 @@

import torch

MAIN_PROC_ONLY = 0
MAIN_PROC_ONLY: int = 0


def run_on_main(
Expand Down Expand Up @@ -74,16 +75,15 @@ def run_on_main(


def if_main_process():
"""Checks if the current process is the main local process and authorized to run
I/O commands. In DDP mode, the main local process is the one with LOCAL_RANK == 0.
In standard mode, the process will not have `LOCAL_RANK` Unix var and will be
authorized to run the I/O commands.
"""Checks if the current process is the main process and authorized to run
I/O commands. The main process is the one with `RANK == 0`. In standard mode,
the process will not have `RANK` Unix var and will be authorized to run the I/O commands.
"""
if "LOCAL_RANK" in os.environ:
if os.environ["LOCAL_RANK"] == "":
if "RANK" in os.environ:
if os.environ["RANK"] == "":
return False
else:
if int(os.environ["LOCAL_RANK"]) == 0:
if int(os.environ["RANK"]) == 0:
return True
return False
return True
Expand Down
Loading