How to set up a Deep Learning environment for the new ARM64 - M1 equipped Macs
There are some things that I assume you have already done/know how to do at this point. I assume your terminal is running natively, and you know some basic BASH. Currently, MiniConda/Anaconda doesn't offer an Apple Silicon version so we need to uninstall it. Enable view of hidden folders with defaults write com.apple.finder AppleShowAllFiles true; killall Finder
, then navigate to .anaconda
and delete it. I installed mine via homebrew so it might be there, or your home folder. Check your terminal and see if it says (base)
upon startup(it shouldn't now),and you should not be able to activate any of your environments. If so, then you successfully deleted it. Next, you need to navigate to https://github.com/conda-forge/miniforge and download the Miniforge3-MacOSX-arm64 version. Navigate to the file in your Downloads using the Terminal and run bash Miniforge3-MacOSX-arm64.sh
. Follow the installation prompt and check your terminal that you have (base)
, then proceed to the next step.
-
Create a conda environment with python 3.8
conda create -n m1_tensorflow python=3.8
-
Download the latest zipped tar file from apple/tensorflow_macos: https://github.com/apple/tensorflow_macos/releases. This install is for version 0.1a1, so if you are installing a newer version at the time of following this guide, adjust that in the code in step 6. XV.
-
Unzip the tar file, I used the native Mac unzip tool. Put it in your home directory, or wherever you prefer.
-
Get the working directory of the 'arm64' folder within that folder, once there, type:
pwd
in the terminal, and copy the output, you will neeed it for the next step. -
Activate the m1_tensorflow environment and set the following variables
libs=(location of arm64 above)
(I usedlibs=“/Users/oresttokovenko/tensorflow_macos/arm64/
)env=(location of your python virtual environment)
(I usedenv=“/Users/oresttokovenko/miniforge3/envs/m1_tensorflow
)
-
Run the following commands in the m1_tensorflow conda environment. I spaced out the conda installs so that if there is an error, it will be easier to determine where that is.
conda install cached-property
conda install six
pip install --upgrade -t "$env/lib/python3.8/site-packages/" --no-dependencies --force "$libs/grpcio-1.33.2-cp38-cp38-macosx_11_0_arm64.whl"
pip install --upgrade -t "$env/lib/python3.8/site-packages/" --no-dependencies --force "$libs/h5py-2.10.0-cp38-cp38-macosx_11_0_arm64.whl"
pip install --upgrade -t "$env/lib/python3.8/site-packages/" --no-dependencies --force "$libs/tensorflow_addons-0.11.2+mlcompute-cp38-cp38-macosx_11_0_arm64.whl"
conda install -c conda-forge -y absl-py
conda install -c conda-forge -y astunparse
conda install -c conda-forge -y gast
conda install -c conda-forge -y opt_einsum
conda install -c conda-forge -y termcolor
conda install -c conda-forge -y typing_extensions
conda install -c conda-forge -y wheel
conda install -c conda-forge -y typeguard
pip install wrapt flatbuffers tensorflow_estimator google_pasta keras_preprocessing protobuf
pip install --upgrade -t "$env/lib/python3.8/site-packages/" --no-dependencies --force "$libs/tensorflow_macos-0.1a1-cp38-cp38-macosx_11_0_arm64.whl"
pip install tensorboard
-
open Jupyter notebook or lab and run
import tensorflow as tf
and check if successful. If you have issues refer to apple/tensorflow_macos#48 (comment) for extra help
- Create a conda environment with python 3.8
conda create -n m1_pytorch python=3.8
- run
conda install pytorch -c isuruf/label/pytorch -c conda-forge
- run
conda install typing-extensions
- open Jupyter notebook or lab and run
import torch
and check if successful. If you have issues refer to pytorch/pytorch#48145 for extra help - Extra Step: Install PyTorch Lightning using
pip install pytorch-lightning
- Extra Step: Install Torchvision using
conda install torchvision -c pytorch
- scikit-learn surprise
- xgboost