Thank you @Akella Niranjan for the reference. For the benefit of community providing solution here as written by @Sihyung Park.
Install TensorFlow-macOS
for Apple Silicon M1
It is easy to install it with the system python since the installation script is given by Apple. However, my goal was to install it with other python so that I can install additional packages for data science without difficulty.
I mainly followed instructions from here to install tensorflow-macos, and then created ipykernel of it so that I can run this environment any time by switching the kernel inside jupyter notebook.
First install miniforge, which natively supports M1. The installation defaults to directory ~/miniforge3/.
Create virtual environment named tf_macos
with conda and install Python 3.8.
conda create -n tf_macos
conda activate tf_macos
conda install -y python=3.8
I specified the version 3.8 so that it matches requirement of tensorflow-macos
.
- Download and install
tensorflow-macos
from Apple Github.
git clone https://github.com/apple/tensorflow_macos.git
cd tensorflow_macos/arm64
pip install --force pip==20.2.4 wheel setuptools cached-property six
pip install --upgrade --no-dependencies --force numpy-1.18.5-cp38-cp38-macosx_11_0_arm64.whl grpcio-1.33.2-cp38-cp38-macosx_11_0_arm64.whl h5py-2.10.0-cp38-cp38-macosx_11_0_arm64.whl tensorflow_addons-0.11.2+mlcompute-cp38-cp38-macosx_11_0_arm64.whl
pip install absl-py astunparse flatbuffers gast google_pasta keras_preprocessing opt_einsum protobuf tensorflow_estimator termcolor typing_extensions wrapt wheel tensorboard typeguard
pip install --upgrade --force --no-dependencies tensorflow_macos-0.1a1-cp38-cp38-macosx_11_0_arm64.whl
- Add the environment as jupyter kernel.
pip install jupyter
python -m ipykernel install --name=tf_macos
Then merely switching the ipython kernel to tf_macos
allows us to use mlcompute-backend TensorFlow without a hassle
- Install additional packages (optional)
conda install scipy pandas matplotlib
For more information you can refer here