Unable to use Nvidia Hardware Encoding
See original GitHub issueTrying 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.
Issue Analytics
- State:
- Created 8 months ago
- Comments:16
Top Results From Across the Web
Nvidia hardware video encoding not working - Linux
Hello. I am trying to get Nvidia hardware encoding working, specifically for ALVR but we may use FFmpeg to test if it's working...
Read more >Hardware Encoding or Acceleration Not Available
I have Acer Nitro 5 with i7- 8750H and Nvidia 1050Ti 4Gb graphics card. I'm not able to use hardware acceleration for 2...
Read more >High-end PC but can't hardware encode. I have a 3950x ...
I'd try a driver update if you haven't. And use the studio drivers. Restart system.
Read more >Unable to enable NVidia NVENC H/W Acel. · Issue #2924
Navigate to Server > Playback. Under "Hardware Acceleration:," select 'Nvidia NVENC'. Check all encoding options. Click "Save" at bottom of page ...
Read more >Hardware Encoding not working? - magix.info
I've read a lot about Hardware Encoding and the issues Magix has with it, but in the process I've learned that their professional-grade ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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:
I know this is a closed/long dead issue but wanted to chime in I’m having the exact same problem. In my case, my older video card doesn’t like the 5XX drivers required for cuda 11.8+. After several attempts, I’ve had to revert back to the 470.X driver with cuda 11.4. Just wondering if there might be any suggestions to getting it working with the older 470x/cuda 11.4 drivers?