Install PyTorch on Apple Silicon Macs (M1, M2, M3, M4) and Check for MPS Availability in 2024

Опубликовано: 28 Июнь 2026
на канале: Dr. Data Science
13,656
109

#pytorch #python #deeplearning

To install PyTorch on a Mac with Apple silicon, follow these steps:

Ensure you have macOS 12.3 or later installed.
Make sure you have Python 3.7 or later installed. You can check your Python version by running python3 --version in your terminal.
Install Xcode command-line tools: xcode-select --install
Next
Install PyTorch: python3 -m pip install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cpu
And verify installation

import torch
print(torch.__version__)
print(torch.backends.mps.is_available()) # Should print True if MPS is available

If the output shows the PyTorch version and True for MPS availability, then PyTorch is installed successfully with MPS (Metal Performance Shaders) support, allowing you to leverage your Apple silicon GPU for accelerated computations.