Uchechukwu Cos-Ibe
4 min readApr 30, 2022

How To Install TensorFlow Version 2.8 on The M1 chip Macbook With Ease

As a data scientist who is also a first-time apple user, I didn’t think much of TensorFlow support for the M1 chip. It took a while, but I have figured out how to install TensorFlow on the new M1 chip.

Installing Homebrew, XCode tools, and Miniforge (Anaconda)

NB: you can skip any above prerequisites if you already have them running on your system.

Homebrew Package Manager for macOS can help install XCode through the terminal.

To install homebrew, go to the official homebrew website https://brew.sh/

Copy the command there into terminal

/bin/bash -c “$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

Next, installing XCode tools. XCode is used to write code and build user interfaces, for this instance, XCode allows us to install and use Miniforge

To install XCode, paste the code below on the terminal

xcode-select –install

If you can’t install XCode tools straight away, please restart the terminal window and try again.

Lastly, to install anaconda, we will install Miniforge because it runs natively on the M1 MacBook.

Go to: https://github.com/conda-forge/miniforge

Click on the “arm64 (Apple Silicon)” and download

It will download an SH file to your defualt download folder. Go to the download path on the terminal and install.

To go to the path, copy the code below to terminal

cd downloads

If the file is not in the downloads folder, replace the downloads with the file path where the Miniforge file is located.

Once you’re in the download folder, to install Miniforge, copy and paste the code below and hit the return/enter key:

chmod -x Miniforge3-MacOSX-arm64.sh
./Miniforge3-MacOSX-arm64.sh

to check if conda was installed, in terminal type:

conda

if it gives no error, congrats! you now have conda installed.

Next, create a new virtual environment based on Python 3.9. you can name it anything you want, but I named mine ds_tf:

conda create — name ds_tf python=3.9

if asked, type “y” to proceed

The new environment will be created:

Then activate the environment:

conda activate ds_tf

We are now ready to install TensorFlow and TensorFlow Metal on the M1 chip

installing TensorFlow dependencies from Apple:

conda install -c apple tensorflow-deps -y

Once done with no errors, use the following command to install TensorFlow on M1 Macbook:

python -m pip install tensorflow-macos

The installation will take a couple of minutes, but It should install without errors and should look like the above picture.

The last step is to install the GPU support for TensorFlow on M1 Pro Macbooks with the Metal plugin:

pip install tensorflow-metal

to test if TensorFlow was installed successfully,

still in the environment, run:

python

once in python, run:

import tensorflow as tf

If it imports without errors, congratulations! TensorFlow is up and running on your machine

To check the version of TensorFlow, run:

tf.__version__

We are currently running TensorFlow version 2.8

Congrats — TensorFlow on the M1 Pro chip was installed successfully.

No responses yet