ErsatzTV: Unable to use Nvidia Hardware Encoding
Trying to run the nvidia docker image and I am unable to get the cuda encoder working. I see this message in the logs:
Error detecting NVIDIA GPU capabilities; some hardware accelerated features will be unavailable: 1
When I run the command ffmpeg -hwaccel cuda -f lavfi -i nullsrc -c:v h264_nvenc -gpu list -f null - 2>&1
within the container, I get this output:
ffmpeg version 5.1.2 Copyright (c) 2000-2022 the FFmpeg developers
built with gcc 11 (Ubuntu 11.3.0-1ubuntu1~22.04)
configuration: --disable-debug --disable-doc --disable-ffplay --enable-ffprobe --enable-cuda --enable-cuda-llvm --enable-cuvid --enable-fontconfig --enable-gpl --enable-libaom --enable-libass --enable-libfdk_aac --enable-libfreetype --enable-libkvazaar --enable-libmp3lame --enable-libnpp --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libsrt --enable-libtheora --enable-libv4l2 --enable-libvidstab --enable-libvmaf --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libxml2 --enable-libx264 --enable-libx265 --enable-libxvid --enable-nonfree --enable-nvdec --enable-nvenc --enable-opencl --enable-openssl --enable-small --enable-stripping --enable-vaapi --enable-vdpau --enable-version3 --extra-cflags='-I/tmp/ffnvcodec/include/ffnvcodec -I/usr/local/cuda/include/' --extra-ldflags='-L/usr/local/cuda/lib64 -L/usr/local/cuda/lib32/' --extra-libs=-ldl --extra-libs=-lpthread
libavutil 57. 28.100 / 57. 28.100
libavcodec 59. 37.100 / 59. 37.100
libavformat 59. 27.100 / 59. 27.100
libavdevice 59. 7.100 / 59. 7.100
libavfilter 8. 44.100 / 8. 44.100
libswscale 6. 7.100 / 6. 7.100
libswresample 4. 7.100 / 4. 7.100
libpostproc 56. 6.100 / 56. 6.100
Input #0, lavfi, from 'nullsrc':
Duration: N/A, start: 0.000000, bitrate: N/A
Stream #0:0: Video: rawvideo (I420 / 0x30323449), yuv420p, 320x240 [SAR 1:1 DAR 4:3], 25 tbr, 25 tbn
[AVHWDeviceContext @ 0x558a924c77c0] cu->cuInit(0) failed -> CUDA_ERROR_COMPAT_NOT_SUPPORTED_ON_DEVICE: forward compatibility was attempted on non supported HW
Device creation failed: -542398533.
[rawvideo @ 0x558a924a8680] No device available for decoder: device type cuda needed for codec rawvideo.
Stream mapping:
Stream #0:0 -> #0:0 (rawvideo (native) -> h264 (h264_nvenc))
Device setup failed for decoder on input stream #0:0 : Generic error in an external library
nvidia-smi
within the container shows the GPU:
root@1caf727c8d77:/app# nvidia-smi
Mon Jan 16 23:46:07 2023
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 470.161.03 Driver Version: 470.161.03 CUDA Version: 11.8 |
|-------------------------------+----------------------+----------------------+
| GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |
| | | MIG M. |
|===============================+======================+======================|
| 0 NVIDIA GeForce ... Off | 00000000:42:00.0 Off | N/A |
| 0% 49C P2 39W / 180W | 501MiB / 8119MiB | 1% Default |
| | | N/A |
+-------------------------------+----------------------+----------------------+
+-----------------------------------------------------------------------------+
| Processes: |
| GPU GI CI PID Type Process name GPU Memory |
| ID ID Usage |
|=============================================================================|
+-----------------------------------------------------------------------------+
Here is my docker-compose file:
version: "3"
services:
ersatztv:
container_name: ersatztv
privileged: true
environment:
- TZ=America/Chicago
- "PUID=${UID}"
- "PGID=${GID}"
- NVIDIA_VISIBLE_DEVICES=all
- NVIDIA_DRIVER_CAPABILITIES=compute,utility,video
image: jasongdove/ersatztv:latest-nvidia
runtime: nvidia
ports:
- 8409:8409/tcp
restart: unless-stopped
volumes:
- /home/docker/ersatztv:/root/.local/share/ersatztv
- /mnt/Media:/media:ro
deploy:
resources:
reservations:
devices:
- capabilities: [ gpu ]
I have another docker container, frigate, that is able to utilize cuda encoding without issue.
About this issue
- Original URL
- State: closed
- Created a year ago
- Comments: 16
Thanks for your help!
One more thing to note, I decided to rm all other 470 libs in the lib folder. This caused docker to not restart nvidia containers, because it was still looking for the 470 libs. To fix this, I had to clear the ld cache: