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, 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 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 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
-r--r--r-- 1 root root   124664 Aug 30 19:21
-r--r--r-- 1 root root   124664 Aug 30 19:21
-r--r--r-- 2 root root   832936 Sep  5 19:11
-r--r--r-- 2 root root  5046944 Sep  5 19:11
-r--r--r-- 2 root root 22716112 Sep  5 19:11
-r--r--r-- 2 root root   878768 Sep  5 19:11
-r--r--r-- 1 root root 40496936 Aug 30 19:21

Yeah, I don’t see, 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