nvidia-patch
nvidia-patch copied to clipboard
Request for WSL 2 drivers
Please provide details about your environment (please complete the following information)
- Nvidia driver version: reported by nvidia-smi
472.12
- GPU Model: GTX 1650 Super
- OS: Ubuntu 21.10 inside WSL 2 running in Win10 21H2
- [x] I'm willing to participate in testing of new patch version
First of all, let me to explain what is WSL and why I ask for this:
- WSL is Windows Subsystem Linux. A technology to run any Linux distribution inside Windows. WSL 2 is using a custom MS Linux kernel using virtualization technologies.
- Inside the WSL 2 runtime the NVIDIA video card is available from stock. Inside the stock Linux environment you will see this directory with MS stuff:
/usr/lib/wsl
. And inside it you can founddrivers
andlib
. - Here is the content in WSL2-Ubuntu:
-
$ ls -l /usr/lib/wsl/lib
:
-
-r-xr-xr-x 1 root root 141464 Sep 14 05:39 libcuda.so
-r-xr-xr-x 1 root root 141464 Sep 14 05:39 libcuda.so.1
-r-xr-xr-x 1 root root 141464 Sep 14 05:39 libcuda.so.1.1
-r-xr-xr-x 2 root root 828840 Sep 28 21:36 libd3d12.so
-r-xr-xr-x 2 root root 4834848 Sep 28 21:36 libd3d12core.so
-r-xr-xr-x 2 root root 878768 Sep 28 21:36 libdxcore.so
-r-xr-xr-x 1 root root 6175952 Sep 14 05:39 libnvcuvid.so.1
-r-xr-xr-x 1 root root 424448 Sep 14 05:39 libnvidia-encode.so.1
-r-xr-xr-x 1 root root 197528 Aug 19 20:56 libnvidia-ml.so.1
-r-xr-xr-x 1 root root 354816 Sep 14 05:39 libnvidia-opticalflow.so.1
-r-xr-xr-x 1 root root 49668400 Sep 14 05:39 libnvwgf2umx.so
-r-xr-xr-x 1 root root 678392 Sep 14 05:39 nvidia-smi
So you can execute any nvidia/cuda software inside this Linux environment and use all your GPUs from Windows. And to enable full support inside the Linux environment you need to patch not the Windows driver, but the libs inside this Linux environment. More or less like you do with Docker and Flatpak. However, the problem is that the driver here is not the stock Linux version, but a bit different. For example, my version is "472.12"; that corresponds to the Windows driver. And this version doesn't exists in the Linux driver catalog.
However, I feel the structure of the binaries/libraries will be very similar to a real Linux driver. So I request to the developers to install this environment (very easy: in any recent Win10 machine, you can install the WSL environment with just a few clicks), and execute the tools to find the entry points of these drivers.
I hope that we'll see soon this project upgraded with WSL drivers support. Regards.
Hi,
One advise: The directory /usr/lib/wsl
is readonly. To do a clean patch of the file, I suggest to use a simple bind of the file. For example with: sudo mount -o bind /opt/nvpatch/libnvidia-encode.so.1 /usr/lib/wsl/lib/libnvidia-encode.so.1
. This will be sufficient to inject the patched driver.
Then we only need that someone finds the correct hooks for this driver. Regards.
In reference to the question of searching for a patch for WSL drivers, see here: https://github.com/illnyang/nvlax/issues/10
Hi,
Good news! I've it working! 🥇
ffmpeg -y -vsync 0 -hwaccel cuda -hwaccel_output_format cuda \
-f lavfi -i testsrc -t 50 \
-vf hwupload -c:a copy -c:v h264_nvenc -b:v 4M -f null - \
-vf hwupload -c:a copy -c:v h264_nvenc -b:v 1M -f null - \
-vf hwupload -c:a copy -c:v h264_nvenc -b:v 8M -f null - \
-vf hwupload -c:a copy -c:v h264_nvenc -b:v 6M -f null -
...
Stream mapping:
Stream #0:0 -> #0:0 (rawvideo (native) -> h264 (h264_nvenc))
Stream #0:0 -> #1:0 (rawvideo (native) -> h264 (h264_nvenc))
Stream #0:0 -> #2:0 (rawvideo (native) -> h264 (h264_nvenc))
Stream #0:0 -> #3:0 (rawvideo (native) -> h264 (h264_nvenc))
...
frame= 560 fps=329 q=8.0 Lq=8.0 q=8.0 q=8.0 size=N/A time=00:00:22.40 bitrate=N/A speed=13.2x
user@windows:~$ uname -a
Linux windows 5.10.60.1-microsoft-standard-WSL2 #1 SMP Wed Aug 25 23:20:18 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
For sure the Windows host has stock nvidia drivers not patched in any form:
C:\>nvidia-smi
Thu Jan 27 14:04:00 2022
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 472.12 Driver Version: 472.12 CUDA Version: 11.4 |
|-------------------------------+----------------------+----------------------+
| GPU Name TCC/WDDM | Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |
| | | MIG M. |
|===============================+======================+======================|
| 0 NVIDIA GeForce ... WDDM | 00000000:01:00.0 On | N/A |
| 20% 32C P8 10W / 100W | 2724MiB / 4096MiB | 18% Default |
| | | N/A |
+-------------------------------+----------------------+----------------------+
+-----------------------------------------------------------------------------+
| Processes: |
| GPU GI CI PID Type Process name GPU Memory |
| ID ID Usage |
|=============================================================================|
...
+-----------------------------------------------------------------------------+
You can found my patch for nvlax here: https://github.com/illnyang/nvlax/issues/10#issuecomment-1023136933
I feel someone will prepare then a PR for this project. Sorry but I don't time to do it for myself.