Skip to content

Fixed: ffmpeg with Hardware acceletarion on Docker Windows Desktop #34

@ehnwebmaster

Description

@ehnwebmaster

Enable the WSL 2 Backend
This is the primary setting that unlocks GPU passthrough.

Open Docker Desktop.
Click the Settings (Gear Icon) in the top-right corner.
Stay on the General tab.
Ensure the box "Use the WSL 2 based engine" is checked.
If you had to check it, click "Apply & Restart".

Check if nvidia-smi is available

docker run --rm --gpus all nvidia/cuda:12.2.0-base-ubuntu22.04 nvidia-smi

Force the use of nvidia

-e VERTD_FORCE_GPU=nvidia

and

-e NVIDIA_DRIVER_CAPABILITIES=all

Errors:

cannot load libnvidia-encode.so.1

Cannot load libnvcuvid.so.1

hwaccel initialisation returned error.

or

ERROR: nvenc requested, but not all dependencies are satisfied: ffnvcodec

How to resolve inside the container:

ldconfig -p | grep nvidia

You should view:

libnvidia-encode.so and libnvcuvid.so

Those libraries are not found in the container so i copied manually from the docker root desktop at Windows

Open shell, cmd

Execute:

wsl

and

cd /usr/lib/wsl/lib

ls

Output

docker-desktop:/usr/lib/wsl/lib# ls
libcuda.so libnvcuvid.so.1 libnvidia-opticalflow.so
libcuda.so.1 libnvdxdlkernels.so libnvidia-opticalflow.so.1
libcuda.so.1.1 libnvidia-encode.so libnvoptix.so.1
libcudadebugger.so.1 libnvidia-encode.so.1 libnvoptix_loader.so.1
libd3d12.so libnvidia-gpucomp.so libnvwgf2umx.so
libd3d12core.so libnvidia-gpucomp.so.580.102.01 nvidia-ngx-updater
libdxcore.so libnvidia-ml.so.1 nvidia-smi
libnvcuvid.so libnvidia-ngx.so.1

Using docker cp copy all the libraries from docker-desktop to the container:

export LD_LIBRARY_PATH=/usr/lib/wsl/lib:$LD_LIBRARY_PATH
ldconfig

How to check:

env | grep NVIDIA

ffmpeg -encoders | grep nvenc

ldconfig -p | grep -E "libavcodec|libnvcuvid"
libnvcuvid.so.1 (libc6,x86-64) => /usr/lib/wsl/lib/libnvcuvid.so.1
libavcodec.so.60 (libc6,x86-64) => /lib/x86_64-linux-gnu/libavcodec.so.60

Docker logs container vertd

starting vertd
working w/ ffmpeg 6.1.1-3ubuntu5 and ffprobe 6.1.1-3ubuntu5
INFO vertd] using GPU from environment variable VERTD_FORCE_GPU: NVIDIA
INFO vertd] detected a NVIDIA GPU -- if this isn't your vendor, open an issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions