[docker]运行指定 GPU

Posted adream307

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了[docker]运行指定 GPU相关的知识,希望对你有一定的参考价值。

docker 内运行运行所有的 GPU

 docker run --rm --gpus all nvidia/cuda:11.0-base nvidia-smi

输出结果

+-----------------------------------------------------------------------------+
| NVIDIA-SMI 450.57       Driver Version: 450.57       CUDA Version: 11.0     |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|                               |                      |               MIG M. |
|===============================+======================+======================|
|   0  GeForce GTX 106...  Off  | 00000000:01:00.0  On |                  N/A |
| 23%   48C    P0    24W / 130W |   1222MiB /  6075MiB |      1%      Default |
|                               |                      |                  N/A |
+-------------------------------+----------------------+----------------------+
|   1  GeForce GTX 106...  Off  | 00000000:03:00.0 Off |                  N/A |
| 48%   33C    P8     6W / 130W |      2MiB /  6078MiB |      0%      Default |
|                               |                      |                  N/A |
+-------------------------------+----------------------+----------------------+
                                                                               
+-----------------------------------------------------------------------------+
| Processes:                                                                  |
|  GPU   GI   CI        PID   Type   Process name                  GPU Memory |
|        ID   ID                                                   Usage      |
|=============================================================================|
+-----------------------------------------------------------------------------+

只运行 1ID1GPU

docker run --rm --gpus "device=1" nvidia/cuda:11.0-base nvidia-smi

输出结果

Mon Sep 14 04:07:29 2020       
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 450.57       Driver Version: 450.57       CUDA Version: 11.0     |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|                               |                      |               MIG M. |
|===============================+======================+======================|
|   0  GeForce GTX 106...  Off  | 00000000:03:00.0 Off |                  N/A |
| 48%   33C    P8     6W / 130W |      2MiB /  6078MiB |      0%      Default |
|                               |                      |                  N/A |
+-------------------------------+----------------------+----------------------+
                                                                               
+-----------------------------------------------------------------------------+
| Processes:                                                                  |
|  GPU   GI   CI        PID   Type   Process name                  GPU Memory |
|        ID   ID                                                   Usage      |
|=============================================================================|
|  No running processes found                                                 |
+-----------------------------------------------------------------------------+

以上是关于[docker]运行指定 GPU的主要内容,如果未能解决你的问题,请参考以下文章

可以在没有 GPU 的情况下运行 nvidia-docker 吗?

sh 在GCP上运行Docker上的tensorflow GPU

docker容器内运行pytorch多gpu报错 RuntimeError: NCCL Error 2: unhandled system error

构建docker环境能够运行自己的GPU服务,能够快速适应不同宿主机的GPU型号操作系统和驱动。linux版本nvidia驱动cudacudnn,docker+conda安装深度学习环境

在 ubuntu 18.04 上升级后,docker tensorflow/gpu 镜像无法运行

docker里找不到gpu