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.11 # Python 3.9 and 3.10 are also supported. conda activate tensorflow-macos
-
Install the
tensorflow
andtensorflow-metal
plugins.pip install tensorflow==2.15.0 pip install tensorflow-metal==1.1.0
-
Install
bazel 6.1.0
.wget https://raw.githubusercontent.com/Homebrew/homebrew-core/a9b3083e23806aebe61f7c39d393734a6949eaa5/Formula/bazel.rb brew install ./bazel.rb bazel --version # Make sure the version is 6.1.0.
- Normally, the version of
bazel
installed viabrew
is the latest one, which may not match the version required by theio
. This can lead to unexpected issues, so we need to manually specify the version for installation.
- Normally, the version of
-
Download and extract
io 0.36.0
.wget https://github.com/tensorflow/io/archive/refs/tags/v0.36.0.zip unzip ./v0.36.0.zip cd io-0.36.0
-
Set the environment variable
TF_PYTHON_VERSION
.export TF_PYTHON_VERSION=3.11 # Python 3.9 and 3.10 are also supported.
-
Run the script.
python tools/build/configure.py bazel build \ ${BAZEL_OPTIMIZATION} \ -- //tensorflow_io_gcs_filesystem/... //tensorflow_io:python/ops/libtensorflow_io.so //tensorflow_io:python/ops/libtensorflow_io_plugins.so
-
Generate
whl
files fortensorflow-io
andtensorflow-io-gcs-filesystem
.python setup.py --data bazel-bin -q bdist_wheel --plat-name macosx_12_0_arm64 rm -rf build python setup.py --project tensorflow-io-gcs-filesystem --data bazel-bin -q bdist_wheel --plat-name macosx_12_0_arm64
-
Please do not forget to install the
whl
file, and you need to installtensorflow-io-gcs-filesystem
first and then installtensorflow-io
.pip install dist/tensorflow_io_gcs_filesystem-*.whl pip install dist/tensorflow_io-*.whl
io
need to correspond with the version oftensorflow
. The specific correspondence is here.- Please ensure that your network is stable during the compilation process, and the compilation needs to use the network.