MPS Back End Out of Memory on GitHub Action

When running a pytest action on GitHub Actions Mac OS, I inconsistently get an error message:

RuntimeError: MPS backend out of memory (MPS allocated: 0 bytes, other allocations: 0 bytes, max allowed: 1.70 GB). Tried to allocate 0 bytes on private pool. Use PYTORCH_MPS_HIGH_WATERMARK_RATIO=0.0 to disable upper limit for memory allocations (may cause system failure).

from a line running'mps')

If I keep re-running the test it eventually succeeds, but sometimes it takes >5 attempts. I don’t understand why the error is occurring or how to prevent it. Setting the environment variable PYTORCH_MPS_HIGH_WATERMARK_RATIO=0.0 as suggested in the error message does not resolve the problem. It occurs, at least occasionally, with Python versions 3.9, 3.10, and 3.11.

The issue does not occur when I run pytest locally on Mac OS with Apple Silicon.

The github action lists the following operating system information:




The installed pytorch is torch (2.0.0)

1 Like


Did you find any solution to this? I have the exact same issue with GitHub workflows, but all tests pass on my local macOS.


Having the same issue (see here and here), but only since 2.1.0.

I don’t have a solution

even GH’s new macos-14 runners don’t have access to MPS hardware unfortunately, see pytorch/pytorch#111449 (comment).