Reputation: 13116
I saw several Q&As on this topic and tried both approaches. Any advice on how to proceed with either route are appreciated:
I followed NVIDIA docs and this tutorial. Everything installs and docker
command runs from within Ubuntu 20.04. However, sudo service docker start
returns:
docker: unrecognized service
Update: this turns to be a known issue. I was able to install and run docker on Ubuntu following these instructions. However, next I am running into an issue like this
$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
Another school of thought suggest removing docker from WSL Ubuntu and running Windows docker instead. Then one can connect to it from WSL. Well, I am not able to run nvidia-docker
from Windows at all:
$ 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]].
Additionally, after removing docker from ubuntu I can still run docker from Ubuntu20.04 or when I run wsl
from Powershell:
$ 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.
I have definitely enabled WSL2-based engine and integration for Ubuntu 20.04 enabled in two different tabs in Docker settings.
Windows 10
WSL 2
Ubuntu 20.04 within WSL2
Windows Docker with WSL2-based engine and integration enabled
Any help how to diagnose it further is much appreciated
Upvotes: 21
Views: 42303
Reputation: 5861
As of June 2022, with Windows 10, I didn't have to do anything to enable this. I have a pre-existing Ubuntu 20.04 install on WSL 2, and Docker running on Windows with WSL 2 integration enabled. I ran docker run -it --rm --gpus all ubuntu nvidia-smi
and it showed my GPU.
Upvotes: 13
Reputation: 1
by https://docs.docker.com/docker-for-windows/wsl/
uncheck "Enable integration with my default WSL distro" and apply,
then uncheck "Use the WSL 2 based engine" and apply.
check all above and enable: "Enable integration with additional distros:" Ubuntu-20.04
open terminal:
docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
it works on my win10 docker 3.6...
Upvotes: -1
Reputation: 73
I think the best way to get nVidia GPU (CUDA) running on WSL2 is to follow the tutorial from nVidia documentation CUDA on WSL. There are three thing you need do them correctly and in order:
After these three steps preformed correctly, you can follow along the nVidia tutorial from Setting up CUDA Toolkit.
Here is another nVidia document stating the same issue you're facing in Chapter 8. They claim that This error usually indicates that the right Microsoft Windows Insider Preview Builds, WSL 2, NVIDIA drivers and NVIDIA Container Toolkit may not be installed correctly.
For me, it was my Windows Insider Preview Builds version not properly set to version 20145 or higher.
Upvotes: 4