text: Errors building tensorflow-text on apple silicon even when using matching versions of tensorflow 2.10
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:
In file included from tensorflow_text/core/kernels/byte_splitter_tflite.cc:18:
external/org_tensorflow/tensorflow/lite/kernels/shim/tflite_op_shim.h:128:35: error: no member named 'OpName' in 'tensorflow::text::ByteSplitterWithOffsetsOp<tflite::shim::Runtime::kTfLite>'
resolver->AddCustom(ImplType::OpName(), GetTfLiteRegistration());
~~~~~~~~~~^
tensorflow_text/core/kernels/byte_splitter_tflite.cc:28:53: note: in instantiation of member function 'tflite::shim::TfLiteOpKernel<tensorflow::text::ByteSplitterWithOffsetsOp>::Add' requested here
tensorflow::text::ByteSplitterWithOffsetsOp>::Add(resolver);
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
conda install -c apple tensorflow-deps=2.10.0
python -m pip install tensorflow-macos==2.10.0
python -m pip install tensorflow-metal==0.6
Bazel is installed from home-brew
brew install bazelisk
Tensorflow-text is downloaded from release page
wget https://github.com/tensorflow/text/archive/refs/tags/v2.10.0.zip
About this issue
- Original URL
- State: open
- Created a year ago
- Reactions: 1
- Comments: 54 (6 by maintainers)
Commits related to this issue
- Fix conditional so it works better with Apple silicon. See issue #1077 for more details. PiperOrigin-RevId: 511600825 — committed to tensorflow/text by broken a year ago
- Fix conditional so it works better with Apple silicon. See issue #1077 for more details. PiperOrigin-RevId: 511600825 — committed to tensorflow/text by broken a year ago
- Fix conditional so it works better with Apple silicon. See issue #1077 for more details. PiperOrigin-RevId: 511829171 — committed to tensorflow/text by broken a year ago
- Fix conditional so it works better with Apple silicon. See issue #1077 for more details. PiperOrigin-RevId: 511829171 — committed to tensorflow/text by broken a year ago
- Fix conditional so it works better with Apple silicon. See issue #1077 for more details. PiperOrigin-RevId: 511829171 — committed to tensorflow/text by broken a year ago
- Fix conditional so it works better with Apple silicon. See issue #1077 for more details. PiperOrigin-RevId: 511829171 — committed to tensorflow/text by broken a year ago
- Fix conditional so it works better with Apple silicon. See issue #1077 for more details. PiperOrigin-RevId: 511829171 — committed to tensorflow/text by broken a year ago
- Force osname check to always be in lower-case. See #1077 PiperOrigin-RevId: 513332105 — committed to tensorflow/text by broken a year ago
- Force osname check to always be in lower-case. See #1077 PiperOrigin-RevId: 513332105 — committed to tensorflow/text by broken a year ago
- Force osname check to always be in lower-case. See #1077 PiperOrigin-RevId: 513332105 — committed to tensorflow/text by broken a year ago
- Force osname check to always be in lower-case. See #1077 PiperOrigin-RevId: 513382587 — committed to tensorflow/text by broken a year ago
- Force osname check to always be in lower-case. See #1077 PiperOrigin-RevId: 513382587 — committed to tensorflow/text by broken a year ago
- Force osname check to always be in lower-case. See #1077 PiperOrigin-RevId: 513382587 — committed to tensorflow/text by broken a year ago
- Force osname check to always be in lower-case. See #1077 PiperOrigin-RevId: 513382587 — committed to tensorflow/text by broken a year ago
- Force osname check to always be in lower-case. See #1077 PiperOrigin-RevId: 513382587 — committed to tensorflow/text by broken a year ago
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. Thanks to @DuongTSon and https://medium.com/@murphy.crosby/building-tensorflow-and-tensorflow-text-on-a-m1-mac-9b90d55e92df
Please make sure:
ld
to workaround the issue mentioned hereFollowing 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
oss_scripts/run_build.sh
: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
ld -v
to make sure your ld version isld64-711
Now run
./oss_scripts/run_build.sh
and the wheel will be produced.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.
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.
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 (
clang -v
), and possibly set ARCHPREFERENCE (if it is used).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 (
file tflite_registrar.so
) to verify they were built for the right architecture. Then you will know for certain whether your created package was built incorrectly or there was an installation issue.I think you are using the master branch to build. I had this issue before, it was because of the error in the script oss_scripts/run_build.sh. You can use the stable versions by checking out at the stable branch such as 2.11, 2.10, etc…
No instruction from this thread worked for me, is there any clear instruction how to build and run it on arm64?
For example when I try to build I have following error:
Which says that
5.3.0 '!=' '5.3.0
Perfect., @DuongTSon , thank you. I guess this issue can be closed, by updating the README to highlight the current version working as well as the environment working.
@ethiel I manage to reproduce your error with the version 2.10 by using the XCode14.2. I guess there was an issue with the XCode 14.2 or clang 14.0. The environment that has worked for me is:
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. https://1drv.ms/u/s!AmRjIZct7QZDg9xM-rf_kE_svoEcJA?e=IvpE7R
However, after manually executing prepare_tf_dep.sh I’m facing a different issue: error: no member named ‘OpName’ in ‘tensorflow::text::FastBertNormalizeOptflite::shim::Runtime::kTfLite’