Blog #pytorch #getting-started #machine-learning
Install PyTorch on Apple M1 (M1, Pro, Max) with GPU (Metal)
Steps to install the PyTorch nightly build with Metal (MPS) GPU support on Apple M1, M1 Pro, and M1 Max, with Miniforge.
- Published
- Updated
- Reading
- 1 min
- Author
- Sudhanva Narayana
Note
- Uninstall Anaconda/Anaconda Navigator and all other conda-based installations.
- Anaconda and Miniforge cannot coexist.
- If you have a previous installation of PyTorch with Miniforge, you can continue to use it. You do not need to uninstall it.
- We install the GPU version in a new
condaenvironment. - The GPU version is still a nightly build, so expect breaking changes for the next couple of months.
Install Miniforge
- Install miniforge from brew:
brew install miniforge - Create a conda environment:
conda create -n pt122 - Activate the environment:
conda activate pt122 - Install Python:
conda install python
Install PyTorch
- Run
pip install --pre torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/nightly/cputo install the PyTorch (Nightly) dependencies. - Run
pip install pandas jupyterlabto install the dependencies for the sample code. - Run
conda activate pt122.
Verify the Installation
- Run
jupyter-labto open a Jupyter Notebook. - Run this code in the notebook:
import torch
torch.device("mps")
torch.__version__
torch.tensor([1,2,3], device="mps")
Credits
Related work
Production ML context
See how this topic connects to production ML systems, infrastructure, and inference.