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
582d104b
Unverified
Commit
582d104b
authored
Jan 23, 2024
by
Zach Mueller
Committed by
GitHub
Jan 23, 2024
Browse files
Fix windows err with checkpoint race conditions (#28637)
Fix windows err
parent
c475eca9
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
3 deletions
+5
-3
src/transformers/trainer.py
src/transformers/trainer.py
+5
-3
No files found.
src/transformers/trainer.py
View file @
582d104b
...
@@ -2415,9 +2415,11 @@ class Trainer:
...
@@ -2415,9 +2415,11 @@ class Trainer:
os
.
rename
(
staging_output_dir
,
output_dir
)
os
.
rename
(
staging_output_dir
,
output_dir
)
# Ensure rename completed in cases where os.rename is not atomic
# Ensure rename completed in cases where os.rename is not atomic
fd
=
os
.
open
(
output_dir
,
os
.
O_RDONLY
)
# And can only happen on non-windows based systems
os
.
fsync
(
fd
)
if
os
.
name
!=
"nt"
:
os
.
close
(
fd
)
fd
=
os
.
open
(
output_dir
,
os
.
O_RDONLY
)
os
.
fsync
(
fd
)
os
.
close
(
fd
)
# Maybe delete some older checkpoints.
# Maybe delete some older checkpoints.
if
self
.
args
.
should_save
:
if
self
.
args
.
should_save
:
...
...
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