-
Notifications
You must be signed in to change notification settings - Fork 344
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Errors building tensorflow-text on apple silicon even when using matching versions of tensorflow 2.10 #1077
Comments
You are not compiling against TF 2.10.0 despite having it installed. That line in tflite_op_shim.h is not a function in version 2.10 and 2.11. So you must be compiling against nightly. In Can you try running |
@broken thanks for the quick reply I will update once the checksum issue go away. |
Now I'm seeing different errors:
|
The protobuf version is 3.19.6 which is pulled by tensorflow-macos 2.10.0 (venv) ➜ text git:(4a098cd) ✗ conda list | grep proto
protobuf 3.19.6 pypi_0 pypi I don't have protoc installed. |
Same issue here, in this case with tensorflow-macos 2.11.0 and protobuf 3.19.4 |
@ethiel how did you get a higher version of tensorflow-macos and a lower version of protobuf? Is the protobuf dependency pulled by tensorflow-macos? Or did you install it separately? |
It was pulled from tensorflow. I did not install any library. |
However, after manually executing prepare_tf_dep.sh I'm facing a different issue: |
I'm afraid we will have to wait for Apple to provide the port for tensor flow-text... I guess there is no way to compile from source as tensorflow-macos was built with different versions, different architecture... |
@ethiel Your error is mismatching versions. On nightly, we switched the shims from using OpName member variable to method. Likely you need to check out the TF Text branch of the version you want to build, run prepare_tf_dep, or something similar. @tsdeng so did @tsdeng Ugh.. This does look closer to a blocker. I have no clue what protoc tensorflow-macos uses. If you are tenacious, you can try reaching out to their GitHub account and ask what version they are using, and update our WORKSPACE file with that version. Or more quickly, I know TF Text v2.9 was successfully built (https://github.com/sun1638650145/Libraries-and-Extensions-for-TensorFlow-for-Apple-Silicon/releases), it looks like that used version 3.9.2 (https://github.com/tensorflow/tensorflow/blob/r2.9/tensorflow/workspace2.bzl#L457). You can try copying that into our WORKSPACE file to see if it works. Bazel should ignore what TF specifies if TF Text defines it first. Make sure you are in a new directory or done a
I'd remove the patch_file, system_build_file, and system_link_files to see if it works. Those may be TF specific and not needed. Otherwise, you may need to copy those files into our own third_party directory from their r2.9 branch. Hopefully this helps. |
@broken I did run After adding the
|
I think I don't have a clear understanding of how protobuf libraries are used and linked in this case. It seems bazel-out/darwin_arm64-opt/bin/external/local_config_tf/include/tensorflow/core/framework/full_type.pb.h is downloaded from a http archive instead of generated on my local machine using protoc. So the After this http archive is downloaded to my machine, it tries to link against some protobuf runtime library and only found newer version and therefore the conflict? What's weird is in my machine I don't have libprotobuf installed so I wonder what is it trying to link against when the error happens. @broken is my understanding correct? In my conda environment only (venv) ➜ text git:(4a098cd) ✗ conda list | grep protobuf
protobuf 3.19.6 pypi_0 pypi |
@tsdeng The protobuf issue can be fixed by using a patch to make it compatible with the Bazel 5.3.0.
However, after fixing the protobuf issue, it has another error which I cannot resolve it yet.
|
https://medium.com/@murphy.crosby/building-tensorflow-and-tensorflow-text-on-a-m1-mac-9b90d55e92df That Tutorial helped me installing Tensorflow-Text on M1 Mac
|
Finally, I have successfully built both the tensorflow-text 2.9 and 2.11. The tensorflow-macos version and the tensorflow-text version should be strictly matched. If you build the text V2.11, then you need to checkout to the 2.11 branch and install the tensorflow-macos=2.11.
|
Thanks for the guide, @DuongTSon. Where did you find the tensorflow-deps==2.11.0?. I tried but the most updated version is 2.9.0 in my channels. |
This is great @DuongTSon! With step 2, are you saying that the conditional is not failing so it's executing the prepare_tf_dep.sh inproperly, or that you need it to execute that line so we need to comment it out? I'm trying to figure out what we need to do to fix it so you no longer need to worry about it. |
@ethiel Sorry, my mistake. Actually we do not need to install tensorflow-deps to build the tensorflow-text on M1 MacOS. Updated my answer! |
@broken Just try to fix that line, actually the condition $osname should be in lowercase.
I have tested this version. It work well on Mac M1 now. |
@DuongTSon thanks, I didn't installed anyway because I didn't find it.
I guess the issue is python 3.10. Python 3.9 with tensorflow-macos 2.9.0 works fine. The issue seems to be in the mix of tensorflow-macos 2.11.0 and the Python version. |
Hey! I was able to create wheel for tensorflow-text==2.10.0 and install tensorflow-macos==2.10.0. But when I try to import them in jupyter notebook, it throws an error Any idea how to solve it? |
@mridulrao it's tensorflow-metal version issue. You can use tensorflow-metal==0.6.0, I have tested with tensorflow-text 2.10. It's working well. |
@DuongTSon Did you build 2.10 from source?. I can't, the build fails with this error: |
@ethiel I was getting the same issue but was able to solve it by using tensorflow==2.10.0 and bazel==5.1.1 |
@DuongTSon I am still getting the same error after downgrading the metal version. I removed tensorflow-metal from the environment but still got the error. The error is coming from |
@mridulrao My build environment is like the following
|
@DuongTSon |
Could I use I precompiled wheel for macos 13 and if yes could someone provide me one? |
I am not sure whether my builds in MacOS Monterey can work on your computer but you can try. There are 3 versions of tensorflow-text 2.9, 2.10, 2.11 in the link below. |
I just tried the Transformer with tensorflow-text in this tutorial https://www.tensorflow.org/text/tutorials/transformer. I havent used the MuRIL encoder! |
…for more details. PiperOrigin-RevId: 511829171
…for more details. PiperOrigin-RevId: 511829171
@DuongTSon I had somebody with a M1 test this, and |
@ethiel For me complication doesn't work, version 2.10.0, I have this error:
Looks like the problem starts here: oss_scripts/prepare_tf_dep.sh So the question is why |
@broken Sorry for the confusion. In the tutorial, I mean we need to disable the About the lowercase In summary, to make the build work with the MacOS M1, we need to disable the |
@DuongTSon OK, I was able to build it, but now there is an error when I try to import:
However I see mentions during the build and it clearly mentions arm64:
|
@DuongTSon Got it; thanks. @vedmant The package you are trying to import was built for the wrong architecture. Some ideas:
|
PiperOrigin-RevId: 513332105
@broken Yes for all questions, installed by pip, the same computer the same environment, and same date. Even if I try to install just |
That's very strange. If you are positive that it's the lib you built, then you must be building it for the wrong architecture somehow. I think your best bet is Google for how to ensure you are building for the right architecture. For example, this page suggests you may have multiple architecture implementations of LLVM installed, check your clang target ( But first, to double verify it is the build, I would unzip your package (just rename with a .zip extension and unzip), and then use the file command ( |
PiperOrigin-RevId: 513332105
PiperOrigin-RevId: 513332105
PiperOrigin-RevId: 513382587
Whoever hitting this problem, here's the solution for everybody using MacOS 13 and want to build tensorflow-text. This is the kind of thing that should not be this hard. Please make sure:
Following are the steps. Create a conda environment:
Install tensorflow macOS dependencies:
clone the tensorflow-text repo and checkout 2.10.0 branch
Comment out following lines in
Backup you ld and replace it with the older version of ld in Xcode 13.1. Here I assume you downloaded Xcode 13 in ~/Downloads folder.
Run Now run I really really hope the tensorflow team can improve the dev experience on Apple Silicon given the huge amount of devs using Mac and all new Macs are on Apple Silicon. |
@tsdeng Thanks, I'll try this, can you upload a built whl file, maybe I just can install it? Actually I was able to build this way as well, but using all this steps in your example. However I have the same error when I try to run it: ImportError: dlopen(/Users/vedmant/Downloads/text-2.10.0/venv/lib/python3.10/site-packages/tensorflow_text/core/pybinds/tflite_registrar.so, 0x0002): tried: '/Users/vedmant/Downloads/text-2.10.0/venv/lib/python3.10/site-packages/tensorflow_text/core/pybinds/tflite_registrar.so' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e')) |
@vedmant I will upload a wheel tonight. You environment seems to have some issues. In no way should you get x86_64. Are you unintentionally running Rosetta? Did you install the apple silicon version of Vonda? |
@tsdeng Not running rosetta, installed environment |
@tsdeng Thanks, this worked, but I have different error now:
It works however if I run on CPU only. |
This is a known issue: https://developer.apple.com/forums/thread/711402 |
I was seeing the same problem (just with
Note that the
My Python 3.10 is installed via Additionally, to make the resulting wheel work, I had to install the older With these two tweaks, the guide by @DuongTSon above works fine. |
I meet a problem when importing tensforflow_text like below: --> from tensorflow_text.core.pybinds import tflite_registrar Could any help to figure out the problem? Thansk a lot my environment: Below is the approach I install the library: Step2: install bazel by (version 5.3.0) Step3: I modified the run_build.sh by specify the version 5.3.0. if [ "$installed_bazel_version" != "5.3.0" ]; then Since the auto generated .bazelversion contains a #Note and always tell me to install 5.3.0 bazel Step4: generate the wheel, succeed with several warnings. Step5: pip install tensorflow_text-2.12.0-cp310-cp310-macosx_11_0_arm64.whl |
Its working great, Thanks to @qitao052 @tsdeng and https://medium.com/@murphy.crosby/building-tensorflow-and-tensorflow-text-on-a-m1-mac-9b90d55e92df . |
For anyone else still hitting this, the fix for me was to edit |
I'm trying to build the tensorflow-text on a M1 Mac because tensorflow-text is not released for Apple silicon.
When compiling using
./oss_scripts/run_build.sh
I see following errors:I would also love to know if anyone is able to get tensorflow-text 2.10 to work on apple silicon.
Setup and reproduce
Tensorflow is installed via conda
Bazel is installed from home-brew
Tensorflow-text is downloaded from release page
The text was updated successfully, but these errors were encountered: