Add ignore_errors=True to trainer.py rmtree in _inner_training_loop (#31668)

Update trainer.py
This commit is contained in:
Nate Brake 2024-07-03 06:54:49 -04:00 committed by GitHub
parent ddfaf11926
commit 65a02cd27d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -2422,7 +2422,7 @@ class Trainer:
for checkpoint in checkpoints_sorted:
if not os.path.samefile(checkpoint, self.state.best_model_checkpoint):
logger.info(f"Deleting older checkpoint [{checkpoint}] due to args.save_total_limit")
shutil.rmtree(checkpoint)
shutil.rmtree(checkpoint, ignore_errors=True)
self.control = self.callback_handler.on_train_end(args, self.state, self.control)