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
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With