running ffmpeg with nvenc inside nvidia docker
Asked Answered
E

2

5

I installed Nvidia Video Codec SDK 8.2 + ffmpeg inside a docker container by using nvidia-docker but when I run this

ffmpeg -f rawvideo -s:v 1920x1080 -r 30 -pix_fmt yuv420p -i HeavyHand_1080p.yuv -c:v h264_nvenc -preset slow -cq 10 -bf 2 -g 150 output.mp4

I got this error

Cannot load libnvidia-encode.so.1

The minimum required Nvidia driver for nvenc is 390.25 or newer Error initializing output stream 0:0 -- Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height

Otherwise nvidia-smi displays this

enter image description here

this gpu used is GeForce 1050 Ti and the cuda version is 9.0

Eustis answered 28/8, 2018 at 16:51 Comment(1)
Maybe tweak the ffmpeg code to tell you what version it thinks it is...Rimini
H
13

When running inside a Docker container, by default not all of Nvidia libraries are mounted inside the container. Read more here and here. You can see all libraries available in your Docker container by running this: ldconfig -p | grep -E 'libcuda|libnvidia'

To fix this, you should modify the NVIDIA_DRIVER_CAPABILITIES environment variable in your Docker image. For example, you can append ENV NVIDIA_DRIVER_CAPABILITIES=all to your Dockerfile to mount all libraries/binaries in your docker container.

By doing so, the libnvidia-encode library will also be mounted, and so FFMPEG will be able to use NVENC codec.

Hieronymus answered 6/12, 2020 at 17:4 Comment(2)
How come your comment isn't the accept answer? You just have to literally do this.Dekeles
Does anyone know what are the actual capabilities needed for this? If I don't want to load "all"Kobarid
L
1

If you are using nvidia-docker for running the docker image then everything should be taken from the host. You should have cuda installed on you host system first. "sudo apt-get install cuda" and then run the docker image.

You should also use the nvidia-cuda image instead of linux (in the dockerfile)

Lastditch answered 11/9, 2018 at 17:4 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.