Install Tensorflow in Apple Silicon

Wenbing Li
2 min readJan 3, 2021

The default Python environment in Apple Silicon is still python 2.7, while python3 command will invoke the python3 runtime. So you can create your own python virtual environment for your work.

python3 -m venv ~/myvenv
source myvenv/bin/activate

Unfortunately, currently there are a lot of python packages with native modules could be not installed because ARM64 prebuilt binaries are not released or the source package compiling failed. For example, tensorflow and numpy.

But there is a workaround to install these two popular AI packages, according to https://github.com/apple/tensorflow_macos, in you newly created python virtual environment, install it by

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/apple/tensorflow_macos/master/scripts/download_and_install.sh)"

During the installation, there will be two prompts to ask if you want to continue and what the virtual environment path is. Answer it and then the scripts will downloads the packages and installs them.

The development stage of these packages are Alpha, which means you play with it but don’t deploy it in the real product environment, since you need to take all risks by yourself.

The following is the package list installed in the virtual environment now

absl-py 0.11.0

appnope 0.1.2

astunparse 1.6.3

backcall 0.2.0

cached-property 1.5.2

cachetools 4.2.0

certifi 2020.12.5

chardet 4.0.0

decorator 4.4.2

flatbuffers 1.12

gast 0.4.0

google-auth 1.24.0

google-auth-oauthlib 0.4.2

google-pasta 0.2.0

grpcio 1.33.2

h5py 2.10.0

idna 2.10

ipython 7.19.0

ipython-genutils 0.2.0

jedi 0.18.0

Keras-Preprocessing 1.1.2

Markdown 3.3.3

numpy 1.18.5

oauthlib 3.1.0

opt-einsum 3.3.0

parso 0.8.1

pexpect 4.8.0

pickleshare 0.7.5

pip 20.3.3

prompt-toolkit 3.0.8

protobuf 3.14.0

ptyprocess 0.7.0

pyasn1 0.4.8

pyasn1-modules 0.2.8

Pygments 2.7.3

requests 2.25.1

requests-oauthlib 1.3.0

rsa 4.6

setuptools 51.1.1

six 1.15.0

tensorboard 2.4.0

tensorboard-plugin-wit 1.7.0

tensorflow-addons 0.11.2

tensorflow-estimator 2.4.0

tensorflow-macos 0.1a1

termcolor 1.1.0

traitlets 5.0.5

typeguard 2.10.0

typing-extensions 3.7.4.3

urllib3 1.26.2

wcwidth 0.2.5

Werkzeug 1.0.1

wheel 0.36.2

wrapt 1.12.1

--

--