我看到了一些关于这个话题的问答,并尝试了两种方法。欢迎任何有关如何继续使用这两种方法的建议:
从WSL2内部运行nvidia-docker
我遵循了NVIDIA文档和这篇教程。一切都安装好了,在Ubuntu 20.04内部运行docker
命令也没有问题。但是,sudo service docker start
返回:
docker: unrecognized service
更新: 这是一个已知问题。我按照这些说明在Ubuntu上安装并运行了docker。然而,接下来我遇到了一个类似的问题。
$docker run --gpus all nvcr.io/nvidia/k8s/cuda-sample:nbody nbody -gpu -benchmark
Status: Downloaded newer image for nvcr.io/nvidia/k8s/cuda-sample:nbody
docker: Error response from daemon: OCI runtime create failed: container_linux.go:370: starting container process caused: process_linux.go:459: container init caused: Running hook #0:: error running hook: exit status 1, stdout: , stderr: nvidia-container-cli: initialization error: nvml error: driver not loaded: unknown.
ERRO[0065] error waiting for container: context canceled
- 在WSL1中有一个类似的问题这里,建议安装WSL2。我在WSL2下也遇到了同样的问题。
从Windows运行NVIDIA Docker:
另一种 思路 是将docker从WSL Ubuntu中删除,改为从Windows上运行docker。然后可以从WSL连接到它。但是,我无法从Windows上运行nvidia-docker
:
$ docker run --gpus all nvcr.io/nvidia/k8s/cuda-sample:nbody nbody -gpu -benchmark
Unable to find image 'nvcr.io/nvidia/k8s/cuda-sample:nbody' locally
nbody: Pulling from nvidia/k8s/cuda-sample
...
docker: Error response from daemon: could not select device driver "" with capabilities: [[gpu]].
- 这里有如何解决这个问题的提示,点击这里,但都是关于在 Linux 系统中运行 Docker 的。而那并不起作用(见上文)。
此外,在从 Ubuntu 删除 Docker 后,我仍然可以从 Ubuntu 20.04 运行 Docker 或者在 Powershell 中运行 wsl
:
$ which docker
/mnt/c/ProgramData/DockerDesktop/version-bin/docker
$ docker
The command 'docker' could not be found in this WSL 2 distro.
We recommend to activate the WSL integration in Docker Desktop settings.
See https://docs.docker.com/docker-for-windows/wsl/ for details.
我已经在Docker设置的两个不同标签中启用了基于WSL2的引擎和Ubuntu 20.04的集成。
系统
Windows 10
WSL 2
Ubuntu 20.04 within WSL2
Windows Docker with WSL2-based engine and integration enabled
任何进一步诊断的帮助都将不胜感激。