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

I'm trying to set up Docker for a Python project on my Mac and want to use MPS (Metal Performance

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!

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744031776a4546692.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信