Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
chenpangpang
transformers
Commits
f116cf59
Commit
f116cf59
authored
Dec 09, 2019
by
Morgan Funtowicz
Browse files
Allow hidding frameworks through environment variables (NO_TF, NO_TORCH).
parent
6e61e060
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
7 deletions
+16
-7
transformers/file_utils.py
transformers/file_utils.py
+16
-7
No files found.
transformers/file_utils.py
View file @
f116cf59
...
...
@@ -27,6 +27,10 @@ from contextlib import contextmanager
logger
=
logging
.
getLogger
(
__name__
)
# pylint: disable=invalid-name
try
:
if
'NO_TF'
in
os
.
environ
and
os
.
environ
[
'NO_TF'
].
upper
()
in
(
'1'
,
'ON'
):
logger
.
info
(
"Found NO_TF, disabling TensorFlow"
)
_tf_available
=
False
else
:
import
tensorflow
as
tf
assert
hasattr
(
tf
,
'__version__'
)
and
int
(
tf
.
__version__
[
0
])
>=
2
_tf_available
=
True
# pylint: disable=invalid-name
...
...
@@ -35,6 +39,10 @@ except (ImportError, AssertionError):
_tf_available
=
False
# pylint: disable=invalid-name
try
:
if
'NO_TORCH'
in
os
.
environ
and
os
.
environ
[
'NO_TORCH'
].
upper
()
in
(
'1'
,
'ON'
):
logger
.
info
(
"Found NO_TORCH, disabling PyTorch"
)
_torch_available
=
False
else
:
import
torch
_torch_available
=
True
# pylint: disable=invalid-name
logger
.
info
(
"PyTorch version {} available."
.
format
(
torch
.
__version__
))
...
...
@@ -77,6 +85,7 @@ def is_torch_available():
return
_torch_available
def
is_tf_available
():
return
_tf_available
if
not
six
.
PY2
:
...
...
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