Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenpangpang
transformers
Commits
de9e3b59
Unverified
Commit
de9e3b59
authored
Jul 27, 2023
by
Pbihao
Committed by
GitHub
Jul 27, 2023
Browse files
fix delete all checkpoints when save_total_limit is set to 1 (#25136)
parent
a0042379
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
1 addition
and
1 deletion
+1
-1
src/transformers/trainer.py
src/transformers/trainer.py
+1
-1
No files found.
src/transformers/trainer.py
View file @
de9e3b59
...
@@ -1960,7 +1960,7 @@ class Trainer:
...
@@ -1960,7 +1960,7 @@ class Trainer:
# Delete the last checkpoint when save_total_limit=1 if it's different from the best checkpoint and process allowed to save.
# Delete the last checkpoint when save_total_limit=1 if it's different from the best checkpoint and process allowed to save.
if
self
.
args
.
should_save
and
self
.
state
.
best_model_checkpoint
is
not
None
and
self
.
args
.
save_total_limit
==
1
:
if
self
.
args
.
should_save
and
self
.
state
.
best_model_checkpoint
is
not
None
and
self
.
args
.
save_total_limit
==
1
:
for
checkpoint
in
checkpoints_sorted
:
for
checkpoint
in
checkpoints_sorted
:
if
checkpoint
!=
self
.
state
.
best_model_checkpoint
:
if
not
os
.
path
.
samefile
(
checkpoint
,
self
.
state
.
best_model_checkpoint
)
:
logger
.
info
(
f
"Deleting older checkpoint [
{
checkpoint
}
] due to args.save_total_limit"
)
logger
.
info
(
f
"Deleting older checkpoint [
{
checkpoint
}
] due to args.save_total_limit"
)
shutil
.
rmtree
(
checkpoint
)
shutil
.
rmtree
(
checkpoint
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment