Skip to content
Merged
Show file tree
Hide file tree
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
5 changes: 4 additions & 1 deletion nemo_run/run/experiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -665,7 +665,10 @@ def run(
return

# Prepare experiment before running
self._prepare()

# in case of multi-node execution with LocalExecutor+torchrun+slurm, run only on first rank
if int(os.getenv("SLURM_PROCID", 0)) == 0:
self._prepare()

if direct:
self.console.log(
Expand Down
3 changes: 3 additions & 0 deletions nemo_run/run/torchx_backend/components/torchrun.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,11 @@ def torchrun(
num_nodes = nnodes_rep
nproc_per_node = str(nproc_per_node)

# set node rank to relative node id in the current allocation
if use_env and os.getenv("NODE_RANK"):
node_rank = os.environ["NODE_RANK"]
elif use_env and os.getenv("SLURM_NODEID"):
node_rank = os.environ["SLURM_NODEID"]
else:
node_rank = torchx_dist._noquote(f"$${ExecutorMacros.NODE_RANK_VAR}")

Expand Down
Loading