Apple-M1-BERT icon indicating copy to clipboard operation
Apple-M1-BERT copied to clipboard

ImportError: TFBertForSequenceClassification requires the TensorFlow library but it was not found in your environment.

Open ankitadhar opened this issue 3 years ago • 2 comments

Even though tensorflow is installed as can be seen below:

python -c 'import tensorflow as tf; print(tf.__version__)' 2.4.0-rc0 upon running following: python dump_tf_graph.py I am getting error that tensorflow library is not found.

Traceback (most recent call last): File "dump_tf_graph.py", line 25, in <module> main() File "/Users/ankitadhar/miniforge3/envs/tf_env/lib/python3.8/site-packages/click/core.py", line 829, in __call__ return self.main(*args, **kwargs) File "/Users/ankitadhar/miniforge3/envs/tf_env/lib/python3.8/site-packages/click/core.py", line 782, in main rv = self.invoke(ctx) File "/Users/ankitadhar/miniforge3/envs/tf_env/lib/python3.8/site-packages/click/core.py", line 1066, in invoke return ctx.invoke(self.callback, **ctx.params) File "/Users/ankitadhar/miniforge3/envs/tf_env/lib/python3.8/site-packages/click/core.py", line 610, in invoke return callback(*args, **kwargs) File "dump_tf_graph.py", line 19, in main model = tf_utils.get_huggingface_model(model_name, batch_size, seq_len) File "/Users/ankitadhar/Documents/NLP/worksheet/git-bert/Apple-M1-BERT/tf_utils.py", line 40, in get_huggingface_model model = _load_keras_model( File "/Users/ankitadhar/Documents/NLP/worksheet/git-bert/Apple-M1-BERT/tf_utils.py", line 21, in _load_keras_model model = module.from_pretrained(name) File "/Users/ankitadhar/miniforge3/envs/tf_env/lib/python3.8/site-packages/transformers/utils/dummy_tf_objects.py", line 372, in from_pretrained requires_tf(self) File "/Users/ankitadhar/miniforge3/envs/tf_env/lib/python3.8/site-packages/transformers/file_utils.py", line 550, in requires_tf raise ImportError(TENSORFLOW_IMPORT_ERROR.format(name)) ImportError: TFBertForSequenceClassification 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.

ankitadhar avatar May 08 '21 14:05 ankitadhar

Have the same issue

ElliotQi avatar May 13 '21 05:05 ElliotQi

Here's a solution @ankitadhar https://id2thomas.medium.com/apple-silicon-experiment-1-installing-huggingface-transformers-2e45392d3d0f

ElliotQi avatar May 13 '21 07:05 ElliotQi