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
52404cba
Unverified
Commit
52404cba
authored
Jun 21, 2022
by
Zachary Mueller
Committed by
GitHub
Jun 21, 2022
Browse files
Properly check for a TPU device (#17802)
parent
ef23fae5
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
3 deletions
+7
-3
src/transformers/utils/import_utils.py
src/transformers/utils/import_utils.py
+7
-3
No files found.
src/transformers/utils/import_utils.py
View file @
52404cba
...
...
@@ -399,12 +399,16 @@ def is_ftfy_available():
def
is_torch_tpu_available
():
if
not
_torch_available
:
return
False
# This test is probably enough, but just in case, we unpack a bit.
if
importlib
.
util
.
find_spec
(
"torch_xla"
)
is
None
:
return
False
if
importlib
.
util
.
find_spec
(
"torch_xla.core"
)
is
None
:
import
torch_xla.core.xla_model
as
xm
# We need to check if `xla_device` can be found, will raise a RuntimeError if not
try
:
xm
.
xla_device
()
return
True
except
RuntimeError
:
return
False
return
importlib
.
util
.
find_spec
(
"torch_xla.core.xla_model"
)
is
not
None
def
is_torchdynamo_available
():
...
...
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