Since Apple’s M1 chip is a really good choice for maschine learning at home, but the setup of a Tensorflow environment isn’t exactly straight forward, I thought it would make sense to simplify it a little bit and write a short guide on how to do it.

What we need and what the finished solution will look like

We need an Apple device with a M1, M1 Pro or Max chip and macOS 12.0 or higher. We will then setup a Conda environment and install all the dependencies for Tensorflow on MacOS. After that we can use a little script to create a new isolaten Tensorflow environment for each of our Tensorflow projects.

Setup Conda

Installing Conda is actually straight forward. Just download the installer script from here and then execute the following commands in a terminal to install Conda to your home directory.

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

Setup a project environment

Everytime we start a new Tensorflow project we now only need to create a new directory and execute a little script I wrote inside of it, to set it up automatically. You can find the script here. I suggest that you just download the script and put it somewhere in your PATH so you can access it from everywhere. Now just enter your new project directory in a terminal and execute the script here. It will setup a Python venv and install everything you need to start your Tensorflow project as well as activate all environments so you can start coding right away. To test it just type python3 in your console and then try if import tensorflow works. If you can execute tensorflow.version now, everything is fine.