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
8db64367
Unverified
Commit
8db64367
authored
Jan 19, 2024
by
Fanli Lin
Committed by
GitHub
Jan 19, 2024
Browse files
Fix wrong xpu device in DistributedType.MULTI_XPU mode (#28386)
* remove elif xpu * remove redudant code
parent
690fe73f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
0 additions
and
11 deletions
+0
-11
src/transformers/training_args.py
src/transformers/training_args.py
+0
-11
No files found.
src/transformers/training_args.py
View file @
8db64367
...
@@ -1844,11 +1844,6 @@ class TrainingArguments:
...
@@ -1844,11 +1844,6 @@ class TrainingArguments:
device
=
torch
.
device
(
"cuda"
,
local_rank
)
device
=
torch
.
device
(
"cuda"
,
local_rank
)
self
.
_n_gpu
=
1
self
.
_n_gpu
=
1
torch
.
cuda
.
set_device
(
device
)
torch
.
cuda
.
set_device
(
device
)
elif
is_torch_xpu_available
()
and
"ACCELERATE_USE_XPU"
not
in
os
.
environ
:
os
.
environ
[
"ACCELERATE_USE_XPU"
]
=
"true"
self
.
distributed_state
=
PartialState
(
timeout
=
timedelta
(
seconds
=
self
.
ddp_timeout
))
device
=
torch
.
device
(
"xpu:0"
)
self
.
_n_gpu
=
1
elif
is_sagemaker_dp_enabled
():
elif
is_sagemaker_dp_enabled
():
self
.
distributed_state
=
PartialState
(
_use_sagemaker_dp
=
True
)
self
.
distributed_state
=
PartialState
(
_use_sagemaker_dp
=
True
)
self
.
_n_gpu
=
1
self
.
_n_gpu
=
1
...
@@ -1877,12 +1872,6 @@ class TrainingArguments:
...
@@ -1877,12 +1872,6 @@ class TrainingArguments:
elif
is_sagemaker_dp_enabled
()
or
is_sagemaker_mp_enabled
():
elif
is_sagemaker_dp_enabled
()
or
is_sagemaker_mp_enabled
():
# Already set _n_gpu
# Already set _n_gpu
pass
pass
elif
self
.
distributed_state
.
distributed_type
==
DistributedType
.
MULTI_XPU
:
if
"ACCELERATE_USE_XPU"
not
in
os
.
environ
:
os
.
environ
[
"ACCELERATE_USE_XPU"
]
=
"true"
self
.
_n_gpu
=
1
device
=
torch
.
device
(
"xpu:0"
)
torch
.
xpu
.
set_device
(
device
)
elif
self
.
distributed_state
.
distributed_type
==
DistributedType
.
NO
:
elif
self
.
distributed_state
.
distributed_type
==
DistributedType
.
NO
:
if
self
.
use_mps_device
:
if
self
.
use_mps_device
:
warnings
.
warn
(
warnings
.
warn
(
...
...
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