最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

python - How to enable MPS acceleration for PyTorch inside Docker on Mac? - Stack Overflow

programmeradmin0浏览0评论

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!

发布评论

评论列表(0)

  1. 暂无评论