如何使用 Docker SDK for Python 运行具有特定 GPU 的 Docker 容器
在命令行中,我习惯使用 --gpus 参数运行/创建具有特定 GPU 的容器:
docker run -it --gpus '"device=0,2"' ubuntu nvidia-smi
Docker SDK for Python 文档不是很有帮助,而且我找不到关于如何使用 python SDK 执行相同操作的良好解释。有办法做到吗?
In the command line I am used to run/create containers with specific GPUs using the --gpus argument:
docker run -it --gpus '"device=0,2"' ubuntu nvidia-smi
The Docker SDK for Python documentation was not very helpful and I could not find a good explanation on how to do the same with the python SDK. Is there a way to do it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是使用 Docker SDK for Python 运行/创建具有特定 GPU 的 docker 容器的方法:
这样您还可以使用此处指定的其他 GPU 资源选项:
https://docs.docker.com/config/containers/resource_constraints/
This is how you can run/create docker containers with specific GPUs using the Docker SDK for Python:
This way you can also use other GPU resource options specified here:
https://docs.docker.com/config/containers/resource_constraints/