2020/9/30

cuda in docker

因為這一篇 說,照一般安裝也可以用。
當然,他提供了三種方法。
所以想試試看直接安裝的方法。
--- 上次在docker 中使用 nvidia ffmpeg,是用 nvidia 的docker。

follow 這一篇,無腦的裝了。

test 有 Error, 要 follow 這一篇 加上 nvidia 的 source list
才能裝
$ sudo apt install nvidia-container-toolkit
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
  libnvidia-container-tools libnvidia-container1
The following NEW packages will be installed:
  libnvidia-container-tools libnvidia-container1 nvidia-container-toolkit
0 upgraded, 3 newly installed, 0 to remove and 51 not upgraded.
Need to get 850 kB of archives.
After this operation, 2,623 kB of additional disk space will be used.
Do you want to continue? [Y/n] 
重新啟動 docker
systemctl restart docker
然後在 container 舊可以正確run nvidia-smi
因為 host 是 10.2:
~/gpuindocker$ cat Dockerfile 
FROM nvidia/cuda:10.2-base
CMD nvidia-smi

build image and run
~/gpuindocker$ docker build . -t nvidia-test

~/gpuindocker$ docker run --gpus all nvidia-test
Thu Oct 29 08:07:02 2020       
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 440.100      Driver Version: 440.100      CUDA Version: 10.2     |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|===============================+======================+======================|
|   0  TITAN RTX           Off  | 00000000:01:00.0 Off |                  N/A |
| 30%   46C    P0    31W / 280W |      0MiB / 24218MiB |      0%      Default |
+-------------------------------+----------------------+----------------------+
                                                                               
+-----------------------------------------------------------------------------+
| Processes:                                                       GPU Memory |
|  GPU       PID   Type   Process name                             Usage      |
|=============================================================================|
|  No running processes found                                                 |
+-----------------------------------------------------------------------------+
這樣在container 中也能正確 access gpu

原來是docker 19.03 版之後,可以不用 nvidia-docker2 來 access gpu
可以直接支援 gpu


沒有留言:

張貼留言