I'm trying to set up Docker for a Python project on my Mac and want to use MPS (Metal Performance Shaders) for GPU acceleration with PyTorch inside the container.
What I have tried so far:
- I installed Docker Desktop (the latest version of Apple Silicon) on MacOS.
- Created a Dockerfile using a base image like python:3.11-slim.
- Installed PyTorch inside the container and checked for MPS availability with:
import torch
print(torch.backends.mps.is_available())
This returns False
, meaning MPS is not detected inside the container.
- Running the same code outside Docker on macOS (bare metal), MPS is available (True).
My questions:
Does Docker on macOS support GPU passthrough for MPS acceleration?
Are there any specific Docker settings or configurations to enable GPU access inside the container?
If GPU passthrough is not supported, are there any workarounds to use MPS with PyTorch inside Docker?
Any guidance or workarounds would be greatly appreciated. Thanks!