It is assumed here that you have the necessary Unix-Like knowledge, brew
and conda
have been installed in your terminal, and the installation and use methods of brew
and conda
will not be repeated here; most importantly, this tutorial is completely based on Apple silicon build, so make sure your Mac is Apple silicon.
-
Create a new Env and install the dependencies provided by Apple.
conda create -n tensorflow-macos python=3.12 # Python 3.9, 3.10 and 3.11 are also supported. conda activate tensorflow-macos
-
Install the
tensorflow
.pip install tensorflow==2.18.0
-
Install
bazel 6.5.0
.wget https://github.com/bazelbuild/bazel/releases/download/6.5.0/bazel-6.5.0-darwin-arm64 -O bazel chmod +x bazel sudo mv bazel /usr/local/bin/ bazel --version # Make sure the version is 6.5.0.
-
Download and extract
text 2.18.1
.wget https://github.com/tensorflow/text/archive/refs/tags/v2.18.1.zip unzip ./v2.18.1.zip cd text-2.18.1
-
Run the script.
./oss_scripts/run_build.sh
-
Please do not forget to install the whl file.
pip install ./*.whl
Text
needs to correspond to a minor version oftensorflow
(e.g.tensorflow-macos==2.7.0
andtensorflow-text==2.7.3
)- Please ensure that your network is stable during the compilation process, and the compilation needs to use the network.
- I add a PR for Apple Silicon support.