Building ffmpeg with nvenc inside docker container in WSL 2 Linux Distro

I am trying to use hardware accelerated ffmpeg to encode videos with nvenc in a Docker container with cuda base image on Linux Distro. I see the nvenc unloaded without any error and encoding throws error.

Actually the Issue is with libnvidia-encode.so, WSL2 architecture doesn’t need NVidia drivers to be on host(WSL Linux Distro), but to be downloaded on Windows only. These encoders doesn’t come with the WSL supported NVidia drivers. So I have to install them separately on WSL Linux Distro and inside my docker container(cuda based image with video processing enabled), it mounts the libnvidia-encode.so file to container which uses it for building ffmpeg. It does detect the encoders .so files but unloads it, may be due to some conflict, which I assume can be WSL-CUDA specific error, since it works fine on my Linux VM.

Ref :

What’s the output of ls -la /usr/lib/wsl/lib/ ?
If you don’t see libnvidia-encode.so there then the CUDA WSL2 driver is not ready yet for your scenario.

Don’t install anything CUDA-driver related inside WSL2. Right now only the libraries that you can find in C:\Windows\System32\lxss\lib can be actually used by WSL2.

dr-xr-xr-x 1 root root     4096 Sep 14 13:41 .
drwxr-xr-x 4 root root     4096 Sep 15 14:01 ..
-r--r--r-- 1 root root   124664 Aug 30 19:21 libcuda.so
-r--r--r-- 1 root root   124664 Aug 30 19:21 libcuda.so.1
-r--r--r-- 1 root root   124664 Aug 30 19:21 libcuda.so.1.1
-r--r--r-- 2 root root   832936 Sep  5 19:11 libd3d12.so
-r--r--r-- 2 root root  5046944 Sep  5 19:11 libd3d12core.so
-r--r--r-- 2 root root 22716112 Sep  5 19:11 libdirectml.so
-r--r--r-- 2 root root   878768 Sep  5 19:11 libdxcore.so
-r--r--r-- 1 root root 40496936 Aug 30 19:21 libnvwgf2umx.so

Yeah, I don’t see libnvidia-encode.so, any timelines when can we expect this to be included in WSL2 drivers, or is there any other way, we can build hwaccel ffmpeg on WSL 2.

Yes, support for encoding/decoding in WSL2 is coming in a future driver. It was confirmed in the WSLConf’s CUDA session.

At minute 30 starts Q&A