无法在 docker 上执行 nvidia 运行时
can't execute nvidia runtime on docker
我正在尝试在我的 centos7 系统上将 nvidia-docker 升级为 运行:
$ cat /etc/systemd/system/docker.service.d/override.conf
[Service]
ExecStart=
ExecStart=/usr/bin/dockerd-current --add-runtime docker-runc=/usr/libexec/docker/docker-runc-current --add-runtime=nvidia=/usr/bin/nvidia-container-runtime --default-runtime=docker-runc --exec-opt native.cgroupdriver=systemd --userland-proxy-path=/usr/libexec/docker/docker-proxy-current --seccomp-profile=/etc/docker/seccomp.json $OPTIONS $DOCKER_STORAGE_OPTIONS $DOCKER_NETWORK_OPTIONS $ADD_REGISTRY $BLOCK_REGISTRY $INSECURE_REGISTRY $REGISTRIES
$ cat /etc/docker/daemon.json
{
}
$ docker --version
Docker version 1.13.1, build 774336d/1.13.1
$ sudo systemctl daemon-reload
$ sudo systemctl restart docker
到目前为止一切顺利:
$ sudo docker run hello-world
Hello from Docker!
This message shows that your installation appears to be working correctly.
To generate this message, Docker took the following steps:
1. The Docker client contacted the Docker daemon.
2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
(amd64)
3. The Docker daemon created a new container from that image which runs the
executable that produces the output you are currently reading.
4. The Docker daemon streamed that output to the Docker client, which sent it
to your terminal.
To try something more ambitious, you can run an Ubuntu container with:
$ docker run -it ubuntu bash
Share images, automate workflows, and more with a free Docker ID:
https://hub.docker.com/
For more examples and ideas, visit:
https://docs.docker.com/engine/userguide/
现在,让我们尝试使用 nvidia 运行时间:
$ sudo docker run --runtime=nvidia --rm nvidia/cuda nvidia-smi
standard_init_linux.go:178: exec user process caused "permission denied"
但奇怪的是...
$ sudo docker run --runtime=nvidia --rm nvidia/cuda sh -c nvidia-smi
Wed May 16 06:41:17 2018
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 390.42 Driver Version: 390.42 |
|-------------------------------+----------------------+----------------------+
| GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |
|===============================+======================+======================|
| 0 Tesla K80 Off | 00000000:06:00.0 Off | 0 |
| N/A 28C P8 26W / 149W | 0MiB / 11441MiB | 0% Default |
+-------------------------------+----------------------+----------------------+
所以...最后我完全禁用了 selinux 并重新启动并修复了它。
我正在尝试在我的 centos7 系统上将 nvidia-docker 升级为 运行:
$ cat /etc/systemd/system/docker.service.d/override.conf
[Service]
ExecStart=
ExecStart=/usr/bin/dockerd-current --add-runtime docker-runc=/usr/libexec/docker/docker-runc-current --add-runtime=nvidia=/usr/bin/nvidia-container-runtime --default-runtime=docker-runc --exec-opt native.cgroupdriver=systemd --userland-proxy-path=/usr/libexec/docker/docker-proxy-current --seccomp-profile=/etc/docker/seccomp.json $OPTIONS $DOCKER_STORAGE_OPTIONS $DOCKER_NETWORK_OPTIONS $ADD_REGISTRY $BLOCK_REGISTRY $INSECURE_REGISTRY $REGISTRIES
$ cat /etc/docker/daemon.json
{
}
$ docker --version
Docker version 1.13.1, build 774336d/1.13.1
$ sudo systemctl daemon-reload
$ sudo systemctl restart docker
到目前为止一切顺利:
$ sudo docker run hello-world
Hello from Docker!
This message shows that your installation appears to be working correctly.
To generate this message, Docker took the following steps:
1. The Docker client contacted the Docker daemon.
2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
(amd64)
3. The Docker daemon created a new container from that image which runs the
executable that produces the output you are currently reading.
4. The Docker daemon streamed that output to the Docker client, which sent it
to your terminal.
To try something more ambitious, you can run an Ubuntu container with:
$ docker run -it ubuntu bash
Share images, automate workflows, and more with a free Docker ID:
https://hub.docker.com/
For more examples and ideas, visit:
https://docs.docker.com/engine/userguide/
现在,让我们尝试使用 nvidia 运行时间:
$ sudo docker run --runtime=nvidia --rm nvidia/cuda nvidia-smi
standard_init_linux.go:178: exec user process caused "permission denied"
但奇怪的是...
$ sudo docker run --runtime=nvidia --rm nvidia/cuda sh -c nvidia-smi
Wed May 16 06:41:17 2018
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 390.42 Driver Version: 390.42 |
|-------------------------------+----------------------+----------------------+
| GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |
|===============================+======================+======================|
| 0 Tesla K80 Off | 00000000:06:00.0 Off | 0 |
| N/A 28C P8 26W / 149W | 0MiB / 11441MiB | 0% Default |
+-------------------------------+----------------------+----------------------+
所以...最后我完全禁用了 selinux 并重新启动并修复了它。