Now Available: CUDA on WSL Public Preview

Can I follow up: Do I need a fresh WSL install to access the drivers, or are they simply loaded with the kernel?

No, you don’t see to reinstall WSL2 or any distro you have running there. However, it is recommended to restart the container if you happened to reinstall the driver. You can do that by shutting down all running distro’s (command: wsl --shutdown) and then starting the distro you need.

Thank you. One more quick question, is it possible to install the Ubuntu CUDA libraries for development without overwriting the WSL driver?

As long as you don’t install any NVidia driver within the WSL2 container itself, you should be fine.

(the driver to support CUDA in WSL comes from the Windows host)

Just as a side note if you install the NVIDIA CUDA Toolkit. Install it via the runfile (and uncheck the Driver Installation). Don’t use the .deb file as it will install the Native driver without giving you the choice and you might have to manually purge this package.

1 Like

I have quick question, if I am using dockerd in WSL2/Ubuntu then do I still need to start Docker Desktop ?

You mean Docker Desktop on Windows host? No, you don’t need to.
Please only start the dockerd service in the WSL2 container.

Thank you @kmorozov . Another question please. I am using VS Code for development and without Docker Desktop I am not able to connect to the Docker container that is running inside WSL2/Ubuntu. I can use the Remote-WSL extension to connect to Ubuntu but how do I attach VS Code to the container that is running within Ubuntu. Any ideas ?

This question is about VSCode support for docker in WSL. I would recommend you to post it to Issues · microsoft/WSL · GitHub forum.

Some related links where you can start as well:

For installing with deb file without installing the driver, just do:

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

I successfully installed CUDA 11 with this method on WSL2.
Reference document: CUDA on WSL :: CUDA Toolkit Documentation (check “Setting up CUDA Toolkit” session)

Thanks @kmorozov. I managed to connect VS Code to the container inside WSL\Ubuntu with below 2 steps :

  1. In WSL/Ubuntu I used the -H flag to open port 2375:
    sudo dockerd -H unix:///var/run/docker.sock -H tcp://
  2. And in VS Code settings.json, added this line :

I have documented entire process that I followed in my blog post How to run Tensorflow using NVIDIA CUDA and Docker on Windows 10 WSL . Hope it helps the community.

Also, I had one question. Currently, we cannot use Docker Desktop for Windows right ? In the future, can we expect this to change ?

1 Like

we cannot use Docker Desktop for Windows right

This is correct since you have the docker support inside the full Linux guest of WSL2 container.

And thank you for documenting how to use VS Code for WSL2 development. Very useful blog post of yours.