Skip to content

Commit b4d4e48

Browse files
Xing Zhao LEExingzhaolee
Xing Zhao LEE
and
xingzhaolee
authored
Run on_validation_end only on main process in DDP (#1125)
Co-authored-by: xingzhaolee <[email protected]>
1 parent b29613b commit b4d4e48

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

pytorch_lightning/callbacks/model_checkpoint.py

+4
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,10 @@ def format_checkpoint_name(self, epoch, metrics, ver=None):
175175
return filepath
176176

177177
def on_validation_end(self, trainer, pl_module):
178+
# only run on main process
179+
if trainer.proc_rank != 0:
180+
return
181+
178182
metrics = trainer.callback_metrics
179183
epoch = trainer.current_epoch
180184
self.epochs_since_last_check += 1

0 commit comments

Comments
 (0)