Skip to content

Commit 497d667

Browse files
Rocketknight1sgugger
authored andcommitted
Fix how we detect the TF package (#24255)
* Fix how we detect the TF package * Add a comment as a talisman warding against future harm * Actually put the comment in the right place
1 parent 65a1ec0 commit 497d667

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/transformers/utils/import_utils.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,9 @@ def _is_package_available(pkg_name: str, return_version: bool = False) -> Union[
146146
_tf_available = True
147147
else:
148148
if USE_TF in ENV_VARS_TRUE_AND_AUTO_VALUES and USE_TORCH not in ENV_VARS_TRUE_VALUES:
149-
_tf_available = _is_package_available("tensorflow")
149+
# Note: _is_package_available("tensorflow") fails for tensorflow-cpu. Please test any changes to the line below
150+
# with tensorflow-cpu to make sure it still works!
151+
_tf_available = importlib.util.find_spec("tensorflow") is not None
150152
if _tf_available:
151153
candidates = (
152154
"tensorflow",

0 commit comments

Comments
 (0)