Skip to content
This repository has been archived by the owner on Nov 1, 2024. It is now read-only.

Fix the bug that the last checkpoint may not be saved properly in some cases #122

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
2 changes: 2 additions & 0 deletions pycls/core/checkpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ def save_checkpoint(model, optimizer, epoch, best):
"""Saves a checkpoint."""
# Save checkpoints only from the master process
if not dist.is_master_proc():
torch.distributed.barrier()
return
# Ensure that the checkpoint dir exists
os.makedirs(get_checkpoint_dir(), exist_ok=True)
Expand All @@ -75,6 +76,7 @@ def save_checkpoint(model, optimizer, epoch, best):
# If best copy checkpoint to the best checkpoint
if best:
copyfile(checkpoint_file, get_checkpoint_best())
torch.distributed.barrier()
return checkpoint_file


Expand Down