Hi - this is for anyone else running into issues. It took me a long time - and lots of google searching - but I’ve got everything working finally.
I assume you have WSL 2 working already. You don’t need to install a WSL distribution yet - we’ll come to that.
ONLY follow the steps upto Installing Nvidia drivers at this stage. Don’t go any further!
Now - to get Docker working - it’s actually very easy! The latest versions of Docker Desktop have their own WSL2 container support - with GPU support! There is a catch though. Use v 3.3.0 for Docker Destop (don’t go any higher!!!). 3.3.3 definitely crashes it. Also - 3.3.0 gives you the option to ignore future updates…
At this stage - you should already have Docker working correctly - even in Windows!! There is another catch - we need to set a flag --env NVIDIA_DISABLE_REQUIRE=1 to get GPU support.
Compute 6.1 CUDA device: [NVIDIA GeForce GTX 1080 Ti]
28672 bodies, total time for 10 iterations: 21.033 ms
= 390.855 billion interactions per second
= 7817.098 single-precision GFLOP/s at 20 flops per interaction
At this stage, if you haven’t installed a WSL distribution yet, you should see the following 2 WSL distributions pop up - as Docker installed them for you. Leave them alone!
(base) PS C:\Users\gyaan> wsl -l -v
NAME STATE VERSION
docker-desktop Running 2
docker-desktop-data Running 2
Now you may install any WSL distribution of your liking. Before going any further - make sure you click this - to enable docker support within WSL directly. Docker may restart when you do so.
Compute 6.1 CUDA device: [NVIDIA GeForce GTX 1080 Ti]
28672 bodies, total time for 10 iterations: 23.429 ms
= 350.881 billion interactions per second
= 7017.623 single-precision GFLOP/s at 20 flops per interaction
Finally - if you want - you can install CUDA natively in that WSL distribution by following the rest of the steps upto the point “Docker installation” on the NVIDIA page. Don’t go any further. You already have Docker working in WSL!!
I had this issue in version 3.3.3 of Docker, but once I uninstalled, rebooted - then re-installed 3.3.0, it worked after that. Someone else also confirmed that this works (see bottom of the github page).
Make sure that after installing 3.3.0 of Docker Desktop from this page, you do not upgrade any further.
Thanks for the guide! The benchmark is up and working for me when I run from windows, however when I try to run the third example (CUDA on WSL :: CUDA Toolkit Documentation) I get:
WARNING: The NVIDIA Driver was not detected. GPU functionality will not be available.
Use 'nvidia-docker run' to start this container
Where you able to run that example correctly and get the NVIDIA drivers detected?
Hi - I was able to get the tensorflow docker image running - if that’s your question. I checked the GPU was exposed in it, and was able to run some test cases. I was also able to install CUDA natively on the WSL (and also on Windows) and run the BlackScholes example (on both).
Sorry I forgot to include that in the post but when I start my docker I use that, Tensorflow can find the GPU so I guess it can work I just don’t know if ill be able to use tensorrt in the container since it says it can’t find drivers
So - I’ve been thinking - why do we need to run containers at all now? I am also able to get tensorflow running natively on Windows (actually that’s what I have been doing last few days) - since they (and also Pytorch) are natively supporting Windows. And everything seems to work just fine.
Maybe using via the WSL Docker just adds too much complexity…
I’m actually going to be running container in the cloud, so having same environment local is a huge win for me. I did go through the steps in original post and everything worked from GPU perspective! However I had to roll back because the latest windows build caused my system to hang and crash every 5 minutes or so. :( so i’m back to square one.
For anyone who, after running the above docker run command in WSL2 got this error (like I did):
permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get http://%2Fvar%2Frun%2Fdocker.sock/v1.39/containers/json: dial unix /var/run/docker.sock: connect: permission denied
The reason is that the user running the command is not a member of the docker group. To add yourself to the docker group, run:
sudo usermod -a -G docker $USER
Then logout and log back in.
After logging back in, confirm you are a member of the docker group by typing:
$ groups
You should see “docker” in the list displayed.
Otherwise, worked great! Just remember, if you copy & paste docker CUDA sample command lines from the NVIDIA pages, remember to add --env NVIDIA_DISABLE_REQUIRE=1 to the line you copied.
Hi - to anyone reading this now - install Docker Desktop 3.5.1.66090 or higher directly. I have verified with both 3.6 and 4.0 - which both seem to work fine, and also no longer require the flag --env NVIDIA_DISABLE_REQUIRE=1.