Skip to content

Commit

Permalink
Clean up staging tmp checkpoint directory (huggingface#28848)
Browse files Browse the repository at this point in the history
clean up remaining tmp checkpoint dir

Signed-off-by: woshiyyya <xiaoyunxuan1998@gmail.com>
  • Loading branch information
woshiyyya authored and steven committed Feb 14, 2024
1 parent 58a6377 commit 2c375d6
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/transformers/trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -2468,6 +2468,10 @@ def _save_checkpoint(self, model, trial, metrics=None):
# Solely rely on numerical checkpoint id for rotation.
# mtime is not reliable especially on some fuse fs in cloud environments.
self._rotate_checkpoints(use_mtime=False, output_dir=run_dir)
elif self.is_local_process_zero():
# Clean up the remaining staging checkpoint folders on other nodes
if staging_output_dir != output_dir and os.path.exists(staging_output_dir):
shutil.rmtree(staging_output_dir)

self.args.distributed_state.wait_for_everyone()

Expand Down

0 comments on commit 2c375d6

Please sign in to comment.