Skip to content

Instantly share code, notes, and snippets.

@maslychm
Created May 18, 2022 20:58
Show Gist options
  • Save maslychm/46644f9fb08eae967163d373d4ae6fb8 to your computer and use it in GitHub Desktop.
Save maslychm/46644f9fb08eae967163d373d4ae6fb8 to your computer and use it in GitHub Desktop.
Install Mac M1 PyTorch GPU support

Install PyTorch 1.12.0 with Mac M1 GPU support (MPS device: for Metal Performance Shaders)

TLDR: Dowload package directly from anaconda.org and install over the current torch version

Explanation

Wrong version (1.10.2) gets installed for me when I run conda install pytorch -c pytorch-nightly.
To fix, install the latest pytorch version from the stable channel, then manually download package for your python version, and install it over the current pytorch. Newest Pytorch Nightly releases here: Anaconda: Pytorch Nightly Files.

Instruction for installing PyTorch 1.12.0 on Mac M1 using Anaconda with Python 3.10.4

First make sure you are using M1 arm version of Anaconda. If not, get it here: Anaconda: Downloads.
Then,

conda create -n mps python=3.10.4
conda activate mps
conda install pytorch torchvision -c pytorch
curl -L 'https://anaconda.org/pytorch-nightly/pytorch/1.12.0.dev20220518/download/osx-arm64/pytorch-1.12.0.dev20220518-py3.10_0.tar.bz2' -o 'pytorch-1.12.0.dev20220518-py3.10_0.tar.bz2'
conda install ./pytorch-1.12.0.dev20220518-py3.10_0.tar.bz2

Don't forget to select the right interpreter! :)

Resources:

Using the MPS device
PyTorch Blog: M1 support announcement
Installing a compressed package
Apple's page on MPS

@Asriel31
Copy link

:)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment