229 words
1 minute
PyTorch

Installing PyTorch (on Apple Silicon Mac)#

To install PyTorch on ny Apple Silicon Mac, e.g. M5, we don’t need a special version. PyTorch natively supports Apple’s GPU acceleration out of the box using Metal Performance Shaders (MPS).

Metal Performance Shaders

Metal Performance Shaders (MPS) is an Apple framework providing highly optimized, GPU-accelerated compute and graphics functions for iOS, iPadOS, and macOS. It lets developers run intensive tasks like machine learning, image processing, and ray tracing efficiently without writing custom code for every GPU architecture.

Follow these straightforward steps to set it up inside a clean Python environment:

  1. Ensure prerequisites are met: Open terminal and make sure command-line tools are installed:

    Terminal window
    xcode-select --install
  2. Create and activate virtual environment: It is best practice to use a virtual environment so our packages stay organized. We can use Python’s built-in venv:

    Terminal window
    # Create a project folder and environment
    python3 -m venv pytorch-env
    source pytorch-env/bin/activate
  3. Install PyTorch: Install the stable, native Apple Silicon version of PyTorch, along with torchvision and torchaudio via pip

    Terminal window
    pip install --upgrade pip
    pip install torch torchvision torchaudio
  4. Verify GPU (MPS) Acceleration: To confirm that PyTorch can successfully talk to our Mac’s GPU, run a quick python check:

    Terminal window
    python3 -c "
    import torch
    if torch.backends.mps.is_available():
    device = torch.device('mps')
    x = torch.ones(1, device=device)
    print('Success! PyTorch is using the GPU:', x)
    else:
    print('MPS device not found. Running on CPU.')
    "

If it outputs tensor([1.], device='mps:0'), our setup is fully ready for high-performance machine learning tasks.

PyTorch
https://blogs.openml.io/posts/pytorch/
Author
OpenML Blogs
Published at
2026-09-14
License
CC BY-NC-SA 4.0