Apple M1/M2 GPU Support in PyTorch: A Step Forward, but Slower than Conventional Nvidia GPU Approaches

Renee LIN
5 min readJun 17, 2023
Apple

I bought my Macbook Air M1 chip at the beginning of 2021. It’s fast and lightweight, but you can’t utilize the GPU for deep learning. Fortunately, my dataset is relatively small, and the 8-core CPU is sufficient. Recently, I have been working on another project, and the training speed is much lower than expected, so I googled utilizing GPU on M1/M2 chip again. It turns out that PyTorch released a new version called Nightly, which allowed utilizing GPU on Mac last year. I tried it and realized it’s still better to use Nvidia GPU.

  1. Installation
  2. Performance comparison

1. Installation

You need to update your system to macOS 12.3+ and install this newest package.

https://pytorch.org/get-started/locally/

I use Conda to create the environment.

conda create -n myenv python=3.8
conda activate myenv
pip3 install --pre torch torchvision torchaudio --index-url https://download.pytorch.org/whl/nightly/cpu

After that, you can use this code to check if the MPS is activated.

--

--

Renee LIN

Passionate about web dev and data analysis. Huge FFXIV fan. Interested in healthcare data now.