apple / tensorflow_macos

TensorFlow for macOS 11.0+ accelerated using Apple's ML Compute framework.
Other
3.67k stars 308 forks source link

Huggingface transformers can't find Tensorflow installation #144

Closed ShawonAshraf closed 3 years ago

ShawonAshraf commented 3 years ago

This is the error I'm getting:

>>> import tensorflow as tf
>>> from transformers import AutoTokenizer
None of PyTorch, TensorFlow >= 2.0, or Flax have been found. Models won't be available and only tokenizers, configuration and file/data utilities can be used.
>>> from transformers import TFBertModel
>>> model = TFBertModel.from_pretrained("bert-base-cased")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/shawon/PyVenvs/tf_macos/lib/python3.8/site-packages/transformers/utils/dummy_tf_objects.py", line 351, in from_pretrained
    requires_tf(self)
  File "/Users/shawon/PyVenvs/tf_macos/lib/python3.8/site-packages/transformers/file_utils.py", line 443, in requires_tf
    raise ImportError(TENSORFLOW_IMPORT_ERROR.format(name))
ImportError: 
TFBertModel requires the TensorFlow library but it was not found in your environment. Checkout the instructions on the
installation page: https://www.tensorflow.org/install and follow the ones that match your environment.
ShawonAshraf commented 3 years ago

Found a fix here. Closing.

https://id2thomas.medium.com/apple-silicon-experiment-1-installing-huggingface-transformers-2e45392d3d0f