Open tsdeng opened 1 year ago
@DuongTSon OK, I was able to build it, but now there is an error when I try to import:
from tensorflow_text.core.pybinds import tflite_registrar ImportError: dlopen(/Users/vedmant/miniconda3/lib/python3.10/site-packages/tensorflow_text/core/pybinds/tflite_registrar.so, 0x0002): tried: '/Users/vedmant/miniconda3/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'))
I was seeing the same problem (just with arm64
instead of arm64e
) and I was reasonably sure that my environment is set up correctly. I fixed/worked around this by explicitly adding --cpu=darwin_arm64
to my .bazelrc
:
# Settings for MacOS on ARM CPUs.
build:macos_arm64 --cpu=darwin_arm64
build:macos_arm64 --macos_minimum_os=11.0
Note that the .bazelrc
is regenerated every time you call oss_scripts/run_build.sh
. To prevent this, I commented out the call to the configure.sh
script like this after running for the first time:
# Run configure.
# source oss_scripts/configure.sh
My Python 3.10 is installed via brew
and not via conda. That might make a difference and explain why only some people see this error - and why it eventually worked for @vedmant after switching to a different Python binary.
Additionally, to make the resulting wheel work, I had to install the older ld
as described above.
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 ImportError: cannot import name 'tflite_registrar' from 'tensorflow_text.core.pybinds' (unknown location)
Could any help to figure out the problem? Thansk a lot
my environment: MacOS 13.3 conda environment Python 3.10.10 tensorflow 2.12.0
Below is the approach I install the library: Step1: git clone https://github.com/tensorflow/text.git cd text git checkout 2.12
Step2: install bazel by (version 5.3.0) ./oss_scripts/install_bazel.sh
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
5.3.0
NOTE: Update Bazel version in tensorflow/tools/ci_build/release/common.sh.oss
Step4: generate the wheel, succeed with several warnings. ./oss_scripts/run_build.sh
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 oss_scripts/run_build.sh
and add --config="macos_arm64"
to bazel build
(i.e. before --enable_runfiles ...
).
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