WSL with CUDA support
Let me save you many hours of pain and just give you the rundown.
* You MUST be on Windows 10 21H2 or above. 21H2 cannot currently be updated to (yeah, it's because they are pushing Windows 11) so you need to download it as an ISO.
* Install the latest "game ready driver" for your card (you don't need a special driver despite the nvidia documentation, I got mine here: https://www.nvidia.com/Download/index.aspx).
* In general you should ignore the nvidia documentation as they make it almost impossible to figure out what combination of cuda & cudnn versions you need.
Steps to install:
1. Open CMD as administrator.
2. Run: wsl --install -d ubuntu
3. Open the Ubuntu WSL and enter the following commands:
# Install CUDA
sudo apt-key adv --fetch-keys http://developer.download.nvidia.com/compute/cuda/repos/ubun...
sudo sh -c 'echo "deb http://developer.download.nvidia.com/compute/cuda/repos/ubun... /" > /etc/apt/sources.list.d/cuda.list'
sudo apt-get update
sudo apt-get --yes install cuda-toolkit-11-2 cuda-toolkit-11-2
sudo sh -c 'echo "deb http://developer.download.nvidia.com/compute/machine-learnin... /" > /etc/apt/sources.list.d/nvidia-machine-learning.list'
sudo apt-get update
sudo apt install cuda-11-2 libcudnn8 libcudnn8-dev
sudo apt install libnvinfer8 libnvinfer-dev libnvinfer-plugin8
# Verify CUDA installation
cd /usr/local/cuda-11.2/samples/4_Finance/BlackScholes
sudo make
./BlackScholes
# Install TensorFlow
sudo apt-get update && sudo apt-get install python3-pip python3-dev
pip3 install tensorflow-gpu
If you are reading this in the future I have some advice:
* Look at this page to get at least an idea of what versions of cuda and cudnn will work together: https://www.tensorflow.org/install/source#gpu
* Use apt-cache search <THING> to see the possible versions, allowing you to guess what you need to install. Good luck.
94 comments
[ 4.6 ms ] story [ 145 ms ] threadI cannot edit my HN post anymore.
* You can do the key fetch, populate both apt sources.list.d files, then do a single `apt-get update && apt-get install --yes` rather than 3 updates and 4 installs.
* You're using both `apt` and `apt-get` and only using `--yes` once (obviously fixed by taking the previous point, but while I'm mentioning things...)
* If all but the last two steps use sudo, maybe consider just making the first step `sudo su` and then `exit` when you're done (very context dependent, but does let you skip needing `sh -c` to populate files)
None of this is anything against you, just some possible improvements to have fewer steps and general stuff I'd mention in a normal code review. And full marks for, y'know, actually documenting it at all and sharing:)
- WSL2. Kernel virtualization feels as native as advertised, e.g., docker in wsl2/ubuntu is fast like docker in native ubuntu, vs. the slowness that is docker in os x
- Ubuntu 20.04 works, if I remember right
- We don't worry as much about library-level versions b/c we run via docker
- OpenCL does not work. There's some bits about intel & amd GPUs, but nada on nvidia
- Many nvidia-smi diagnostics do not work... and many ecosystem libraries assumed they did for stuff like initialization & memory management & monitoring. Prepare for whackamole of updating pydata etc. dependencies to ~December+
- TBD for GPU K8S; KinD/K3D seem likely via docker runtime passthrough, but minikube & friends seem riskier. Curious if anyone has that working in a non-painful setup, esp. w/ cross-container GPU sharing..
We still can't fully use+endorse WSL2 support for Nvidia hardware due to lack of even super minimal OpenCL versions, and risky core diagnostics surprises, but encouraging!
(Good time to shout: if you're curious about end-to-end client/server GPU computing and already active on opengl/webgl, we're looking for someone into helping the next 100X of our viz engine!)
This is planned to be fixed. WSL2’s GPU support currently doesn’t provide a path to provide an alternate OpenCL loader ICD location. (And not for OpenGL either)
Microsoft is developing CLon12 at https://github.com/microsoft/OpenCLOn12 as the option to provide OpenCL out of the box.
By the way, if you are ready to have a _limited_ implementation without a full feature set because of Vulkan API limitations, clvk is a thing. The list of limitations of that approach is at https://github.com/google/clspv/blob/master/docs/OpenCLCOnVu...
tldr: Vulkan and OpenCL SPIR-V dialects are different, and the former has significant limitations affecting this use case
---
Interesting, thanks:
* OpenCL 1.2 -> DX12 coverage seems to be passing the repo's tests
* Unclear what's left for either a manual build or an automatic/upstreamed mesa install (https://devblogs.microsoft.com/directx/directx-heart-linux/). We saw the priority examples for the project during announce was ARM/mobile (2020), so still curious...
https://support.microsoft.com/en-us/topic/kb5003791-update-t...
Why do some people need to be so obnoxiously judgemental about other people's choice of OS?
So I shouldn't be allowed to use a certain platform of my choice because you think this somehow impacts you?
Based on your logic how about you stop consuming water, oxygen, real-estate and food because it's making it more difficult for me, in a tiny way, to get those items.
>You will write software for that OS. You will convince others to use that OS. You will tell your boss to get computers with that OS installed
Please stop making false claims about me. You don't know me buddy.
I'm not going to respond to the sentences you added after I posted this comment, because I don't think they add very much.
I also like that I can keep a lot of my development tools separated by WSL distro/container. A few weeks ago I found a video transcoding tool that needed a dependency from Ubuntu 18.04. I was using Ubuntu 20.04 in WSL at the time. So I just downloaded 18.04 from the Store, spun that up in a new terminal tab, and set up the transcoding tool there. I only access that version when I need to do certain transcoding and have preserved my 20.04 for everything else.
Up until this point I've completely avoided Windows for work (for obvious reasons). I've exclusively used a Linux laptop for work.
I use Windows on my desktop as my home machine. WSL means I can train machine learning models in my time off, without stopping me chilling out with my buddies.
FWIW, I just checked on my system, and it totally had the option to download and update to 21H2. Which I'm currently running. So it is available to some systems.
i’m kind of glad they kept the security in place for once rather than backwards compatible at all cost
you can force windows 11 if want to deal with the penalty. it will just warn you it doesn’t pass performance baseline - there are videos and websites that explain how to force it and ignore compatibility checks. just search for bypass system requirements windows 11
If you follow the MS docs, they do not mention anything about install CUDA on the Linux VM, you do not get a functional setup to start using CUDA and if you follow Nvidia's documentation, they push you down the docker container route. I personally prefer to setup Tensorflow using Anaconda rather than pip.
A slight correct on the OP, the special driver NVIDIA mentions is for CUDA only (no display driver included), Nvidia does not "support" installing of their full display driver in WSL2 so YMMV in terms of reliability and performance.
I personally gave up on WSL2, not because of WSL2, but because it is so hard to use remotely (I do not have frequent local access to my GPU workstation). I tried various instructions and WSL2 itself was fine when used locally (via remote desktop), but networking scripts I found were unreliable, or if I used Windows openssh server it kept crashing and bash.exe is too limited to be useful, just not worth the hassle and effort when I can install Linux native.
As an aside: it supports blocking by client identifier, which completely shut down bot connections (and probably will until OpenSSH does the same).
I went back to dual boot configuration with Ubuntu 20.04 LTS, and it saves so much time on fiddling with wsl, I highly recommend it.
Install the cuda driver: https://developer.nvidia.com/cuda/wsl
Install an ubuntu image using wsld, (wsld -i ubuntu -d cuda -o D:\.wsl2)
apt update && apt install nvidia-cuda-toolkit
Done.
For installing cudnn maybe is better to go to the installation guide: https://docs.nvidia.com/deeplearning/cudnn/install-guide/ind...
It suffices to have full Vulkan support. Then we can use Kompute, which is portable to any GPU, not just NVIDIA.
- modern Windows Terminal
- winget
Things have become really cool for devs in the Windows world, I almost don’t have complaints these days :)
(other than GUI related stuff and that Windows Insider is really unstable, but I guess that’s on me for using the dev channel)
Use VSCode as Windows process (if you prefer) as your WSL2 editor; extensions can be installed on WSL2.
I also use Python + OpenCV4.5 + cudnn (CUDA) for computer vision work leveraging GPU compute.
Just an outstanding addition to Win10. WSLg on Win11 adds graphics and pulse audio.
https://www.serialporttool.com/GK/comm-tunnel/
Open Comm Tunnel and setup for your com port (from device manager) and port 2101
Then in WSL2 use socat to connect: socat -d -d tcp-connect:172.18.96.1:2101 pty,raw,echo=0
It will output something like: >socat[18786] N PTY is /dev/pts/2
Then from within WSL2 you know to use '/dev/pts/2' as the COM port for serial and it will connect to the COM port.
It works most of the time for me, but Comm Port seems lag if the throughput gets too much for it to handle.
If Microsoft really "loved Linux" they'd release their own version of Wine. Let us use their programs on our OS, instead of vice versa! Never forget that this relationship is fundamentally adversarial.
You can also force an upgrade using Group Policy: https://www.tenforums.com/tutorials/159624-how-specify-targe...
(this doesn’t work on the Home edition though)
21H2 didn't automatically update on my system but it was clearly available to me in Windows Update and I just clicked to update to it last week, and it did the update.
I'm on Windows 10 Home.
ssh win-PC wsl
give you the same result as SSHing directly into WSL distro?
So, having an SSH server in Windows, that only exists so I can run the `wsl` command, doesn't seem very useful. I'd rather the SSH server be hosted directly in the WSL VM itself and skip the intermediary step.
Thats what all the historic stuff was written on.
Also, much better to go with opencl than cuda for new developments these days (unless you are being funded in one of the nvidia startup programs)