Skip to content

Commit ca68cac

Browse files
Sync working directory with all processes when using Hydra (#5629)
* Append current work dir (hydra dir) to ensure all processes reference the same directory * Add changelog * Add different job name for DDP child processes to log to Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
1 parent 5fcca4e commit ca68cac

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
2929
- Fixed `toggle_optimizer` to reset `requieres_grad` state ([#5574](https://github.com/PyTorchLightning/pytorch-lightning/pull/5574))
3030

3131

32+
- Fixed FileNotFoundError for best checkpoint when using DDP with Hydra ([#5629](https://github.com/PyTorchLightning/pytorch-lightning/pull/5629))
33+
34+
3235
- Fixed an error when logging a progress bar metric with a reserved name ([#5620](https://github.com/PyTorchLightning/pytorch-lightning/pull/5620))
3336

3437

pytorch_lightning/accelerators/ddp_accelerator.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,11 +134,16 @@ def _call_children_scripts(self):
134134
del env_copy['PL_GLOBAL_SEED']
135135

136136
# start process
137-
# if hydra is available and initialized, make sure to set the cwd correctly
137+
# if hydra is available and initialized, make sure to set the original cwd correctly
138+
# and pass current cwd for ddp processes (which hydra has overridden)
138139
cwd: Optional[str] = None
139140
if HYDRA_AVAILABLE:
140141
if HydraConfig.initialized():
141142
cwd = get_original_cwd()
143+
command += [
144+
f'hydra.run.dir={os.getcwd()}',
145+
f'hydra.job.name=train_ddp_process_{local_rank}'
146+
]
142147
proc = subprocess.Popen(command, env=env_copy, cwd=cwd)
143148
self.interactive_ddp_procs.append(proc)
144149

0 commit comments

Comments
 (0)