Skip to content

This is a step by step guide for people who want to install Tensorflow module on their M1 Macs

Notifications You must be signed in to change notification settings

Au-Jonathan/Tensorflow-Installation-guide-for-Apple-silicon-Macs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 

Repository files navigation

Tensorflow-Installation-guide-for-Apple-silicon-Macs

This is a step-by-step guide for people who want to install Tensorflow modules on M1 Mac. You can now leverage Apple’s tensorflow-metal PluggableDevice in TensorFlow v2.5 for accelerated training on Mac GPUs directly with Metal

1*nzaiZv6656n20mLw8Sv7Vw

Using the conventional installation method will return a dead kernal❗️

Screen Shot 2022-03-14 at 16 46 09

Reference Articles: How To Install TensorFlow on M1 Mac (The Easy Way) | by Prabhat Kumar Sahu | Medium Tensorflow Plugin - Metal - Apple Developer

Step 1: Install Homebrew

Go to the website The Missing Package Manager for macOS (or Linux) — Homebrew, copy the following into terminal:

Screen Shot 2022-03-14 at 16 30 46

Screen Shot 2022-03-14 at 17 01 50

Step 2: Install Xcode by typing the following in terminal

xcode-select --install

Step 3: Install Miniforge

Download “Conda env” from the link, drag it to your download folder Tensorflow Plugin - Metal - Apple Developer

Screen Shot 2022-03-14 at 16 34 50

Follow the instructions on the web: copy the codes into terminal: Screen Shot 2022-03-14 at 16 36 23

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

sh ~/Downloads/Miniforge3-MacOSX-arm64.sh

Screen Shot 2022-03-14 at 16 38 27

Keep pressing yes/return to proceed with the installation, until it ask you “Do you wish the installer to initialize Miniforge3?” I typed no as I don’t want it to initialize every time.

Step 4: Activate the new environment miniforge3 that we have just created, then install tensorflow

source ~/miniforge3/bin/activate

conda install -c apple tensorflow-deps

python -m pip install tensorflow-macos

python -m pip install tensorflow-metal

conda install -c conda-forge -y pandas jupyter

conda install numpy

(At a later stage it may complain not having NumPy so we can install it beforehand)

Step 5: Launch Jupiter notebook and test it out

jupyter notebook

In the notebook, try the following:

import tensorflow as tf

print(“Num GPUs Available: “, len(tf.config.experimental.list_physical_devices(‘GPU’)))

It should not return any error ✅✅✅

Screen Shot 2022-03-14 at 16 44 56

Remember to activate this environment everytime you wanted to use tensorflow, Using the default one with Anaconda will always return me a dead kernel once I started to import tensorflow in Jupiter notebook

source ~/miniforge3/bin/activate jupiter notebook

You can always check the python and see which direcotry it's pointing. I have Anaconda3 to initialize everytime and it's required to activate miniforge3 to get tensorflow working

Screen Shot 2022-03-14 at 16 54 28

About

This is a step by step guide for people who want to install Tensorflow module on their M1 Macs

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published