How to Install WSL2 together with Ubuntu and NVIDIA-Docker for Windows 10 -

How to Install WSL2 together with Ubuntu and NVIDIA-Docker for Windows 10

21 June 2021

OS: Windows 10 Pro (Build 21376)

CPU: Intel i7-10870H

RAM: 16 GB

GPU: NVIDIA® GeForce RTX 3060 Laptop GPU (6 GB)

 How to install Windows 10 Insider Build


NVIDIA® GPU applied PC

Microsoft account (to register for the Windows Insider Program)

NVIDIA® Developer Program Membership (to install NVIDIA® Drivers for CUDA on WSL)

First, we will register for the Microsoft Windows Insider Program in Web browser, select the “Dev Channel” and install the latest build from the Dev Channel.

Required Version: 20145 or higher

Recommended Version: 21332 and higher (with Linux Kernel 5.4.91+ for the best performance)

In Web browser, follow these steps: click “Register” → “Sign In Now” → Accept the Terms of Agreement and “Register Now” → “Flight Now” → “Open Settings”.

In Settings, follow these steps: click “Get Started” → “Link an Account” → Sign in with your Microsoft account → select “Dev Channel” → click “Confirm” → “Restart Now”.

Enable “Receive updates for other Microsoft products when you update Windows” in Advanced Update Options.

Click “Check for updates” and reboot Windows.

The Windows OS updated successfully. For the version check, follow “System” → “About” in Settings.

As you can see, our version is “Dev” and the OS build is “21376.1”.

How to install NVIDIA® GPU Driver for Windows 10

Download and install the NVIDIA® Driver from the download section on the “CUDA on WSL page”.

Open Windows PowerShell and type “nvidia-smi.exe” to check the driver package installed.

How to install WSL 2 

As the WSL Installation Guide for Windows 10 document, open PowerShell as Administrator and type:

dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart

dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart

Reboot Windows, open PowerShell as Administrator again and type to set WSL 2 as the default version when installing a new Linux distribution:

wsl.exe --set-default-version 2

Check the updates after the WSL installed.

Wait for a while to checking the updates ended.

Check the Linux kernel version from Settings and PowerShell (with “wsl cat /proc/version” command).

If your kernel version is not 4.19.121 or higher, you can update your kernel with this command:

wsl.exe --update

If that does not work, make sure you have “Receive updates for other Microsoft products when you update Windows” checked and re-run Windows updates.

Install Ubuntu with NVIDIA®-Docker in WSL 2

Install the new Windows Terminal from the Microsoft Store to GPU acceleration, that improves the Ubuntu experience on WSL 2 over the traditional Windows console.

Open Ubuntu from the Windows Terminal and complete your WSL 2 user configurations.

In Ubuntu, install CUDA Toolkit and run the “deviceQuery” example (Our NVIDIA® GPU driver’s CUDA version is 11.3. If your version is different, keep attention to install the same version of cuda-toolkit.).


sudo apt-key adv --fetch-keys

sudo sh -c 'echo "deb /" > /etc/apt/sources.list.d/cuda.list'

sudo apt-get update

sudo apt-get install -y cuda-toolkit-11-3

cd /usr/local/cuda/samples/1_Utilities/deviceQuery

sudo make


Then, continue to install the Docker packages with these commands (Our nvidia-docker did not work for version 1.4.0. We found the solution as downgrading the nvidia-docker packages and disabling requirements checking (NVIDIA_DISABLE_REQUIRE) in “docker run” commands.):


curl | shdistribution=$(. /etc/os-release;echo $ID$VERSION_ID)

curl -s -L | sudo apt-key add -

curl -s -L$distribution/nvidia-docker.list | sudo tee /etc/apt/sources.list.d/nvidia-docker.list

curl -s -L$distribution/libnvidia-container-experimental.list

sudo apt-get update

sudo apt-get install -y nvidia-docker2

sudo apt-get install nvidia-docker2:amd64=2.5.0-1 nvidia-container-runtime:amd64=3.4.0-1 nvidia-container-toolkit:amd64=1.4.2-1 libnvidia-container-tools:amd64=1.3.3-1 libnvidia-container1:amd64=1.3.3-1

sudo service docker stop

sudo service docker start

sudo docker run --rm --gpus all --env NVIDIA_DISABLE_REQUIRE=1 nbody -gpu -benchmark

Thank you for reading our blog post.