pytorch - 💡(How to fix) Fix MPS unavailable on macOS 26.3.1 arm64, and `device="mps"` reports incorrect macOS requirement [9 comments, 5 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
pytorch/pytorch#177819Fetched 2026-04-08 01:01:42
View on GitHub
Comments
9
Participants
5
Timeline
73
Reactions
0
Author
Timeline (top)
mentioned ×25subscribed ×25labeled ×10commented ×9

Error Message

RuntimeError: The MPS backend is supported on macOS 14.0+. Current OS version can be queried using sw_vers

Code Example

torch.backends.mps.is_built() == True
torch.backends.mps.is_available() == False
torch.mps.device_count() == 0

---

RuntimeError: The MPS backend is supported on macOS 14.0+. Current OS version can be queried using `sw_vers`

---

import platform
import subprocess
import sys
import torch

print(platform.platform())
print(platform.machine())
print(sys.version)
print(subprocess.run(["sw_vers"], check=True, capture_output=True, text=True).stdout)

print("torch", torch.__version__)
print("mps_built", torch.backends.mps.is_built())
print("mps_available", torch.backends.mps.is_available())
print("mps_device_count", torch.mps.device_count())

print(torch.ones(1, device="mps"))

---

mps_built: True
mps_available: False
mps_device_count: 0

---

RuntimeError: The MPS backend is supported on macOS 14.0+. Current OS version can be queried using `sw_vers`

---

== System ==
platform: macOS-26.3.1-arm64-arm-64bit
machine: arm64
python: 3.12.13 (main, Mar 10 2026, 18:18:07) [Clang 21.1.4 ]
ProductName:        macOS
ProductVersion:     26.3.1
BuildVersion:       25D2128

== Torch ==
torch: 2.10.0
mps_built: True
mps_available: False
mps_device_count: 0

== MPS Tensor Test ==
tensor_error: RuntimeError: The MPS backend is supported on MacOS 14.0+. Current OS version can be queried using `sw_vers`

---

== System ==
platform: macOS-26.3.1-arm64-arm-64bit
machine: arm64
python: 3.12.13 (main, Mar 10 2026, 18:18:07) [Clang 21.1.4 ]
ProductName:        macOS
ProductVersion:     26.3.1
BuildVersion:       25D2128

== Torch ==
torch: 2.12.0.dev20260318
mps_built: True
mps_available: False
mps_device_count: 0

== MPS Tensor Test ==
tensor_error: RuntimeError: The MPS backend is supported on macOS 14.0+. Current OS version can be queried using `sw_vers`

---

at::mps::MPSDevice::getName() const
RAW_BUFFERClick to expand / collapse

🐛 Describe the bug

MPS unavailable on macOS 26.3.1 arm64, and device="mps" reports incorrect macOS requirement

Versions

  • PyTorch: 2.10.0
  • PyTorch nightly: 2.12.0.dev20260318
  • Python: 3.12.13
  • OS: macOS 26.3.1
  • Architecture: arm64
  • Hardware: Apple M2 Max

Issue description

On an Apple Silicon Mac with Metal support, PyTorch reports that MPS is built but unavailable:

torch.backends.mps.is_built() == True
torch.backends.mps.is_available() == False
torch.mps.device_count() == 0

Trying to create a tensor on device="mps" raises:

RuntimeError: The MPS backend is supported on macOS 14.0+. Current OS version can be queried using `sw_vers`

However, sw_vers reports macOS 26.3.1.

This reproduces with both 2.10.0 and nightly 2.12.0.dev20260318.

Repro

import platform
import subprocess
import sys
import torch

print(platform.platform())
print(platform.machine())
print(sys.version)
print(subprocess.run(["sw_vers"], check=True, capture_output=True, text=True).stdout)

print("torch", torch.__version__)
print("mps_built", torch.backends.mps.is_built())
print("mps_available", torch.backends.mps.is_available())
print("mps_device_count", torch.mps.device_count())

print(torch.ones(1, device="mps"))

Expected behavior

MPS should be available on this machine, and torch.ones(1, device="mps") should succeed.

Actual behavior

For both stable and nightly:

mps_built: True
mps_available: False
mps_device_count: 0

And:

RuntimeError: The MPS backend is supported on macOS 14.0+. Current OS version can be queried using `sw_vers`

Full output

PyTorch 2.10.0

== System ==
platform: macOS-26.3.1-arm64-arm-64bit
machine: arm64
python: 3.12.13 (main, Mar 10 2026, 18:18:07) [Clang 21.1.4 ]
ProductName:        macOS
ProductVersion:     26.3.1
BuildVersion:       25D2128

== Torch ==
torch: 2.10.0
mps_built: True
mps_available: False
mps_device_count: 0

== MPS Tensor Test ==
tensor_error: RuntimeError: The MPS backend is supported on MacOS 14.0+. Current OS version can be queried using `sw_vers`

PyTorch 2.12.0.dev20260318

== System ==
platform: macOS-26.3.1-arm64-arm-64bit
machine: arm64
python: 3.12.13 (main, Mar 10 2026, 18:18:07) [Clang 21.1.4 ]
ProductName:        macOS
ProductVersion:     26.3.1
BuildVersion:       25D2128

== Torch ==
torch: 2.12.0.dev20260318
mps_built: True
mps_available: False
mps_device_count: 0

== MPS Tensor Test ==
tensor_error: RuntimeError: The MPS backend is supported on macOS 14.0+. Current OS version can be queried using `sw_vers`

Additional context

  • system_profiler SPDisplaysDataType reports Metal: Supported
  • No MPS_*, PYTORCH_*, TORCH_*, or CUDA_* environment variables were set
  • Torch libraries are linked against Metal.framework, MetalPerformanceShaders.framework, and MetalPerformanceShadersGraph.framework

An earlier check also triggered a crash when querying device name. The crash report shows:

at::mps::MPSDevice::getName() const

Versions

Versions of relevant libraries: [pip3] numpy==2.4.3 [pip3] onnxruntime==1.24.4 [pip3] torch==2.10.0 [pip3] torchvision==0.25.0 [conda] numpy 1.26.4 pypi_0 pypi [conda] numpydoc 1.9.0 py313h7eb115d_0 [conda] optree 0.19.0 pypi_0 pypi [conda] tbb 2022.0.0 h48ca7d4_0 [conda] torch 2.10.0 pypi_0 pypi

cc @malfet @aditvenk @snadampal @milpuz01 @aditew01 @nikhil-arm @fadara01 @nWEIdia @kulinseth @DenisVieriu97 @jhavukainen

extent analysis

Fix Plan

The issue seems to be related to the version checking logic in PyTorch for MPS support on macOS. To fix this, we can try the following steps:

  • Update PyTorch to the latest version.
  • If the issue persists, try setting the PYTORCH_ENABLE_MPS_FALLBACK environment variable to 1 before running your PyTorch code.

Here's an example of how to set the environment variable in Python:

import os
os.environ['PYTORCH_ENABLE_MPS_FALLBACK'] = '1'

Alternatively, you can set the environment variable outside of your Python code, depending on your operating system.

Verification

To verify that the fix worked, you can run the following code:

import torch
print(torch.backends.mps.is_built())
print(torch.backends.mps.is_available())
print(torch.mps.device_count())

print(torch.ones(1, device="mps"))

If the fix was successful, torch.backends.mps.is_available() should return True, and torch.ones(1, device="mps") should succeed without raising a RuntimeError.

Extra Tips

  • Make sure your macOS version is compatible with the version of PyTorch you are using.
  • If you are using a virtual environment, ensure that the environment variables are set correctly within the virtual environment.
  • If the issue persists, try reinstalling PyTorch or seeking further assistance from the PyTorch community.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

FAQ

Expected behavior

MPS should be available on this machine, and torch.ones(1, device="mps") should succeed.

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING