sun1638650145 / Libraries-and-Extensions-for-TensorFlow-for-Apple-Silicon

This Repo will provide TensorFlow libraries and extended build tutorials that require compilation to build, as well as pre-compiled wheel files.
115 stars 9 forks source link

Error when trying to import tensorflow_text #2

Closed jbmaxwell closed 2 years ago

jbmaxwell commented 2 years ago

First off, thanks for writing this tutorial!

The process seemed to go okay, but I'm getting an error when trying to import tensorflow_text in python:

>>> import tensorflow_text as text
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/jbmaxwell/src/text-2.8.2/tensorflow_text/__init__.py", line 20, in <module>
    from tensorflow_text.core.pybinds import tflite_registrar
ImportError: cannot import name 'tflite_registrar' from 'tensorflow_text.core.pybinds' (unknown location)

It seems like a problem with the install.

I tried re-launching my shell session, but then I just get a ModuleNotFoundError: No module named 'tensorflow_text', as if it was never installed. Any idea what might be going on? Is there somewhere in particular I should run the bazel and text installs?

PS -- I'm running macOS 12.3, Xcode 13.2.1, on a 16" MacBook Pro M1 Pro.

sun1638650145 commented 2 years ago

This error is that you are running directly from the source folder of text.

jbmaxwell commented 2 years ago

Well, it doesn't exclusively happen from that folder. If I cd to another folder, start python, and try to import, I get the following:

>>> import tensorflow_text as text
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'tensorflow_text'
>>> 

Everything seems to go okay during the install, so I'm confused as to why it's not being found...

I see quite a few warnings during the build, like was built for newer macOS version (12.3) than being linked (12.1), but the build does finish.

jbmaxwell commented 2 years ago

Okay, I got it. Not being super experienced with Python I didn't realize I had to do: pip install tensorflow_text-2.8.2-cp39-cp39-macosx_11_0_arm64.whl to actually install the module. It might be good to finish the tutorial with this step.

Thanks again for the tutorial!

sun1638650145 commented 2 years ago

I'm glad you solved your problem. Then, I'll add hints at your suggestion.

stromal commented 2 years ago

CODE

pip install ./*.whl

ERROR

ERROR: tensorflow_text-2.9.0-cp38-cp38-macosx_10_9_x86_64.whl is not a supported wheel on this platform.
sun1638650145 commented 2 years ago

@stromal According to the tag you did not build an arm64 package. This tutorial does not discuss about intel Mac.

maurlco commented 1 year ago

Thank you @sun1638650145 for your tutorial - I am new to python and ML and struggle to import/run tensorflow-text on my M1 macOS.

I followed all the steps (no problem so far) until step 7 : ==> Please do not forget to install the whl file: ==> pip install ./*.whl

(tensorflow-macos) (Projet 4) ➜ text-2.9.0 git:(main) ✗ pip install ./*.whl result: zsh: no matches found: ./*.whl

I tried to replace ./*.whl by 'tensorflow_text-2.9.0-cp38-cp38-macosx_10_9_x86_64.whl' or 'tensorflow_text-2.8.2-cp39-cp39-macosx_11_0_arm64.whl' to see if it would find something.

(tensorflow-macos) (Projet 4) ➜ Projet 4 git:(main) ✗ pip install tensorflow_text-2.9.0-cp38-cp38-macosx_10_9_x86_64.whl result: WARNING: Requirement 'tensorflow_text-2.9.0-cp38-cp38-macosx_10_9_x86_64.whl' looks like a filename, but the file does not exist ERROR: tensorflow_text-2.9.0-cp38-cp38-macosx_10_9_x86_64.whl is not a supported wheel on this platform.

I guess that I need to download a 'tensorflow-text.whl' file before doing the pip install ./*.whl but don't know where to find it.

### Could you please provide more details for the last STEP 7 ? Where should I find the whl file ? Thanks

sun1638650145 commented 1 year ago

@maurlco You can download the precompiled whl file I provided from here. In fact, step 7 is the least important step, it just prompts you to install the whl file. I suggest you provide me with more information, and check your own toolchain for version errors.