In May 2022, PyTorch officially introduced GPU support for Mac M1 chips. It has been an exciting news for Mac users. Let’s go over the installation and test its performance for PyTorch. I have written an article about installing and running TensorFlow on Mac M1 GPU.
To get started, the following Apple’s document would be useful: https://developer.apple.com/metal/pytorch/
Step 1: Environment setup with Apple Silicon
curl -O https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-arm64.sh
sh Miniconda3-latest-MacOSX-arm64.sh
Step 2: Install
Step 3: Verify
Success! Let’s compare the performance of running PyTorch on M1 and CPU.
Test 1: Multiply a 50M-dimensional PyTorch array with a random integer