Skip to content

Commit b4d4e48

Browse files
Xing Zhao LEExingzhaolee
andauthored
Run on_validation_end only on main process in DDP (Lightning-AI#1125)
Co-authored-by: xingzhaolee <xingzhaolee@users.noreply.github.com>
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

Lines changed: 4 additions & 0 deletions
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)