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
84bac652
Unverified
Commit
84bac652
authored
May 31, 2023
by
Zachary Mueller
Committed by
GitHub
May 31, 2023
Browse files
Move import check to before state reset (#23906)
* Move import check to before state reset * Guard better
parent
e42869b0
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
6 deletions
+6
-6
src/transformers/training_args.py
src/transformers/training_args.py
+6
-6
No files found.
src/transformers/training_args.py
View file @
84bac652
...
...
@@ -1667,12 +1667,12 @@ class TrainingArguments:
def
_setup_devices
(
self
)
->
"torch.device"
:
requires_backends
(
self
,
[
"torch"
])
logger
.
info
(
"PyTorch: setting up devices"
)
AcceleratorState
.
_reset_state
()
PartialState
.
_reset_state
()
if
not
is_sagemaker_mp_enabled
()
and
not
is_accelerate_available
(
check_partial_state
=
True
):
if
not
is_sagemaker_mp_enabled
():
if
not
is_accelerate_available
(
check_partial_state
=
True
):
raise
ImportError
(
"Using the `Trainer` with `PyTorch` requires `accelerate>=0.19.0`: Please run `pip install transformers[torch]` or `pip install accelerate -U`"
)
AcceleratorState
.
_reset_state
(
reset_partial_state
=
True
)
self
.
distributed_state
=
None
if
self
.
no_cuda
:
self
.
distributed_state
=
PartialState
(
cpu
=
True
,
backend
=
self
.
ddp_backend
)
...
...
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