This guide ensures the installation of Python (miniconda) and PyTorch runs using the Apple silicon on a M1 Pro (I know the M1 Max probably has no issues) - os specs:
System Software Overview:
System Version: macOS 12.1
Kernel Version: Darwin 21.2.0
Boot Volume: Macintosh HD
Secure Virtual Memory: Enabled
Hardware:
Hardware Overview:
Model Name: MacBook Pro
Model Identifier: MacBookPro18,3
Chip: Apple M1 Pro
Total Number of Cores: 10 (8 performance and 2 efficiency)
Unfortunately this guide or this one did not work form me as homebrew
kept on installing the Intel
based miniconda
, sure this will change soon!
A lot of the steps is taken from here, which was very helpful!
- Don't use homebrew as currently it installs for the Intel platofrm, rather download the
miniforge
installation file for M1 architecture (below is the link).
https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-MacOSX-arm64.sh
- Make the downloaded
miniforge
installation file executable
chmod +x ~/Downloads/Miniforge3-MacOSX-arm64.sh
- Install
miniforge
sh ~/Downloads/Miniforge3-MacOSX-arm64.sh
- Close & open the terminal once installed - then check the
platfrom
by runningconda info
in the terminal you need to seeosx-arm64
conda version : 4.11.0
conda-build version : not installed
python version : 3.9.7.final.0
platform : osx-arm64
- Create a conda environment
conda create --name pytorch_env python=3.9
- Activate this environment and install
pytorch
and for my pursposestorchvision
conda activate pytorch_env
conda install -c pytorch pytorch torchvision
- Save this
main.py
file in a directory and run it locally
python main.py
If it works should see the Kind
field in Activity monitor show Apple
and not Intel
Intel MKL FATAL ERROR: Cannot load libmkl_core.dylib
This means you've installed an Intel
based miniconda / miniforge
- ensure that the installation .sh
file from miniforge
here has the arm64
extension.
from PIL import Image, ImageOps, ImageEnhance, PILLOW_VERSION ImportError: cannot import name 'PILLOW_VERSION' from 'PIL
This is a strange torchvision
issue, if you run conda list
you will see your torch vision version is old
tk 8.6.11 he1e0b03_1 conda-forge
torchvision 0.2.2 py_3 pytorch
To fix this I needed to install version 0.11.2
to match my pytorch
version of 1.10.2
so ran,
conda install torchvision==0.11.2 -c pytorch
see the torchvision repo for which version to match your pytorch
installation.