Installing TensorFlow on Apple Silicon Macs

Installing TensorFlow on Apple Silicon Macs
Photo by Vincent Yuan @USA / Unsplash

1 Introduction

Although Apple Silicon Macs have shown outstanding performance, compatibility issues still cannot be ignored for ordinary users. Installing TensorFlow on Apple Silicon is not as simple as typing pip install tensorflow on Intel Macs. However, numerous developers and Apple itself are working tirelessly to optimize Apple Silicon Macs. Now, installing TensorFlow on Apple Silicon has become much easier. This article will share the recommended method for installing TensorFlow on Apple Silicon Macs. We recommend bookmarking this article for future use!

2 Confirm the Machine Type

This tutorial is suitable for Apple Silicon Macs. You can confirm the machine type by clicking the Apple logo on the top navigation bar and selecting “About This Mac”. Be sure to identify the Apple Silicon Mac.

Please confirm that it is Apple Silicon Macs

3 Install TensorFlow

3.1 Install Conda

First, download Conda: https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-MacOSX-arm64.sh

The downloaded file will appear in the download folder by default (~/Downloads/). Open the terminal and run the following command:

Terminal on Mac
chmod +x ~/Downloads/Miniforge3-MacOSX-arm64.sh
sh ~/Downloads/Miniforge3-MacOSX-arm64.sh

Follow the prompts to install, and then activate the Conda environment:

source ~/miniforge3/bin/activate

3.2 Install TensorFlow Dependencies

After activating the Conda environment, you can install the dependencies required by TensorFlow. The command is as follows:

conda install -c apple tensorflow-deps

When installing a new version of TensorFlow, Apple recommends doing the following first:

# Uninstall the existing tensorflow-macos and tensorflow-metal
python -m pip uninstall tensorflow-macos
python -m pip uninstall tensorflow-metal
# Upgrade tensorflow-deps
conda install -c apple tensorflow-deps --force-reinstall

3.3 Install TensorFlow

Continue to run the following command in the terminal:

python -m pip install tensorflow-macos

4 Use TensorFlow

You can first install Jupyter Notebook, the command is as follows:

conda install notebook -y

Then, start Jupyter Notebook to test whether TensorFlow has been successfully installed, and run the following command:

jupyter notebook

Create a new notebook and import TensorFlow for inspection:

TensorFlow on Apple Silicon Macs

5 Conclusion

The above tutorial has been tested and is very easy to install. Do you have another reason to change to a new computer? It is said that the new Apple Silicon Mac will meet with us before November 2021. Let's go together!