frigate icon indicating copy to clipboard operation
frigate copied to clipboard

[HW Accel Support]: Request to provide complete and precise documentation on how to make nVidia hwaccel work start to finish

Open LukasMojzis opened this issue 2 years ago • 6 comments

Describe the problem you are having

The documentation expects prior knowledge of making nVidia acceleration work in the container. But even as I am able to run nvidia-smi in the container (after installing nvidia-smi package), the ffmpeg process fails, complaining about missing libnvcuvid.so.1

Version

0.11.1-2eada21

Frigate config file

...
ffmpeg:
  global_args: -hide_banner -loglevel info
  input_args: -avoid_negative_ts make_zero -fflags +genpts+discardcorrupt -rtsp_transport tcp -timeout 5000000
  hwaccel_args: -hwaccel vaapi -hwaccel_device /dev/dri/renderD129 -hwaccel_output_format yuv420p # works fine
  hwaccel_args: -c:v h264_cuvid # doesn't work
...

docker-compose file or Docker CLI command

version: "3.9"
services:
  mosquitto:
    ...

  frigate:
    container_name: frigate
    privileged: true
    restart: unless-stopped
    image: blakeblackshear/frigate:stable
    runtime: nvidia
    deploy:
      resources:
        reservations:
          devices:
            - capabilities: [gpu]
    depends_on:
      - mosquitto
    shm_size: "1024mb"
    volumes:
      - /dev/bus/usb:/dev/bus/usb
      - /etc/localtime:/etc/localtime:ro
      - ./frigate/config.yml:/config/config.yml:ro
      - ./frigate/storage:/media/frigate
      - clips:/media/frigate/clips
      - recordings:/media/frigate/recordings
      - type: tmpfs
        target: /tmp/cache
        tmpfs:
          size: 1073741824
    networks:
      *REDACTED*

networks:
      *REDACTED*

volumes:
      *REDACTED*

Relevant log output

frigate  | [s6-init] making user provided files available at /var/run/s6/etc...exited 0.
frigate  | [s6-init] ensuring user provided files have correct perms...exited 0.
frigate  | [fix-attrs.d] applying ownership & permissions fixes...
frigate  | [fix-attrs.d] done.
frigate  | [cont-init.d] executing container initialization scripts...
frigate  | [cont-init.d] done.
frigate  | [services.d] starting services
frigate  | [services.d] done.
frigate  | [2022-12-30 13:11:29] frigate.app                    INFO    : Starting Frigate (0.11.1-2eada21)
frigate  | Starting migrations
frigate  | [2022-12-30 13:11:29] peewee_migrate                 INFO    : Starting migrations
frigate  | There is nothing to migrate
frigate  | [2022-12-30 13:11:29] peewee_migrate                 INFO    : There is nothing to migrate
frigate  | [2022-12-30 13:11:30] detector.coral                 INFO    : Starting detection process: 215
frigate  | [2022-12-30 13:11:30] frigate.app                    INFO    : Output process started: 217
frigate  | [2022-12-30 13:11:30] frigate.app                    INFO    : Camera processor started for *Camera2*: 221
frigate  | [2022-12-30 13:11:30] frigate.app                    INFO    : Camera processor started for *Camera3*: 223
frigate  | [2022-12-30 13:11:30] frigate.app                    INFO    : Camera processor started for *Camera4*: 224
frigate  | [2022-12-30 13:11:30] ws4py                          INFO    : Using epoll
frigate  | [2022-12-30 13:11:30] frigate.edgetpu                INFO    : Attempting to load TPU as usb
frigate  | [2022-12-30 13:11:30] frigate.app                    INFO    : Camera processor started for *Camera5*: 226
frigate  | [2022-12-30 13:11:30] frigate.app                    INFO    : Camera processor started for *Camera6*: 230
frigate  | [2022-12-30 13:11:31] frigate.video                  ERROR   : *Camera1*: Unable to read frames from ffmpeg process.
frigate  | [2022-12-30 13:11:31] frigate.video                  ERROR   : *Camera4*: Unable to read frames from ffmpeg process.
frigate  | [2022-12-30 13:11:31] frigate.video                  ERROR   : *Camera5*: Unable to read frames from ffmpeg process.
frigate  | [2022-12-30 13:11:31] frigate.video                  ERROR   : *Camera5*: ffmpeg process is not running. exiting capture thread...
frigate  | [2022-12-30 13:11:31] frigate.video                  ERROR   : *Camera4*: ffmpeg process is not running. exiting capture thread...
frigate  | [2022-12-30 13:11:32] frigate.video                  ERROR   : *Camera2*: Unable to read frames from ffmpeg process.
frigate  | [2022-12-30 13:11:32] frigate.video                  ERROR   : *Camera2*: ffmpeg process is not running. exiting capture thread...
frigate  | [2022-12-30 13:11:32] frigate.video                  ERROR   : *Camera7*: Unable to read frames from ffmpeg process.
frigate  | [2022-12-30 13:11:32] frigate.video                  ERROR   : *Camera7*: ffmpeg process is not running. exiting capture thread...
frigate  | [2022-12-30 13:11:31] frigate.video                  ERROR   : *Camera1*: ffmpeg process is not running. exiting capture thread...
frigate  | [2022-12-30 13:11:31] frigate.video                  ERROR   : *Camera6*: Unable to read frames from ffmpeg process.
frigate  | [2022-12-30 13:11:31] frigate.video                  ERROR   : *Camera3*: Unable to read frames from ffmpeg process.
frigate  | [2022-12-30 13:11:30] frigate.app                    INFO    : Camera processor started for *Camera7*: 231
frigate  | [2022-12-30 13:11:30] frigate.output                 WARNING : Unable to read frigate logo
frigate  | [2022-12-30 13:11:30] frigate.app                    INFO    : Camera processor started for *Camera1*: 233
frigate  | [2022-12-30 13:11:30] frigate.app                    INFO    : Capture process started for *Camera2*: 234
frigate  | [2022-12-30 13:11:30] frigate.app                    INFO    : Capture process started for *Camera3*: 235
frigate  | [2022-12-30 13:11:30] frigate.app                    INFO    : Capture process started for *Camera4*: 239
frigate  | [2022-12-30 13:11:30] frigate.app                    INFO    : Capture process started for *Camera5*: 242
frigate  | [2022-12-30 13:11:30] frigate.app                    INFO    : Capture process started for *Camera6*: 247
frigate  | [2022-12-30 13:11:30] frigate.app                    INFO    : Capture process started for *Camera7*: 257
frigate  | [2022-12-30 13:11:30] frigate.app                    INFO    : Capture process started for *Camera1*: 262
frigate  | [2022-12-30 13:11:30] ws4py                          INFO    : Using epoll
frigate  | [2022-12-30 13:11:31] frigate.video                  ERROR   : *Camera6*: ffmpeg process is not running. exiting capture thread...
frigate  | [2022-12-30 13:11:31] frigate.video                  ERROR   : *Camera3*: ffmpeg process is not running. exiting capture thread...
frigate  | [2022-12-30 13:11:33] frigate.edgetpu                INFO    : TPU found
frigate  | [2022-12-30 13:11:50] watchdog.*Camera4*                ERROR   : Ffmpeg process crashed unexpectedly for *Camera4*.
frigate  | [2022-12-30 13:11:50] watchdog.*Camera4*                ERROR   : The following ffmpeg logs include the last 100 lines prior to exit.
frigate  | [2022-12-30 13:11:50] ffmpeg.*Camera4*.detect           ERROR   : Input #0, rtsp, from '*RTSP*':
frigate  | [2022-12-30 13:11:50] ffmpeg.*Camera4*.detect           ERROR   :   Metadata:
frigate  | [2022-12-30 13:11:50] ffmpeg.*Camera4*.detect           ERROR   :     title           : IP Camera Video
frigate  | [2022-12-30 13:11:50] ffmpeg.*Camera4*.detect           ERROR   :     comment         : videoMain
frigate  | [2022-12-30 13:11:50] ffmpeg.*Camera4*.detect           ERROR   :   Duration: N/A, start: 0.000000, bitrate: N/A
frigate  | [2022-12-30 13:11:50] ffmpeg.*Camera4*.detect           ERROR   :   Stream #0:0: Video: h264 (Main), yuvj420p(pc, progressive), 1920x1080, 30 fps, 30 tbr, 90k tbn
frigate  | [2022-12-30 13:11:50] ffmpeg.*Camera4*.detect           ERROR   :   Stream #0:1: Data: none
frigate  | [2022-12-30 13:11:50] ffmpeg.*Camera4*.detect           ERROR   : [h264_cuvid @ 0x5580c15aff80] Cannot load libnvcuvid.so.1
frigate  | [2022-12-30 13:11:50] ffmpeg.*Camera4*.detect           ERROR   : [h264_cuvid @ 0x5580c15aff80] Failed loading nvcuvid.
frigate  | [2022-12-30 13:11:50] ffmpeg.*Camera4*.detect           ERROR   : Stream mapping:
frigate  | [2022-12-30 13:11:50] ffmpeg.*Camera4*.detect           ERROR   :   Stream #0:0 -> #0:0 (copy)
frigate  | [2022-12-30 13:11:50] ffmpeg.*Camera4*.detect           ERROR   :   Stream #0:0 -> #1:0 (copy)
frigate  | [2022-12-30 13:11:50] ffmpeg.*Camera4*.detect           ERROR   :   Stream #0:0 -> #2:0 (h264 (h264_cuvid) -> rawvideo (native))
frigate  | [2022-12-30 13:11:50] ffmpeg.*Camera4*.detect           ERROR   : Error while opening decoder for input stream #0:0 : Operation not permitted
frigate  | [2022-12-30 13:11:50] watchdog.*Camera2*            ERROR   : Ffmpeg process crashed unexpectedly for *Camera2*.
frigate  | [2022-12-30 13:11:50] watchdog.*Camera2*            ERROR   : The following ffmpeg logs include the last 100 lines prior to exit.
frigate  | [2022-12-30 13:11:50] ffmpeg.*Camera2*.detect       ERROR   : Input #0, rtsp, from '*RTSP*':
frigate  | [2022-12-30 13:11:50] ffmpeg.*Camera2*.detect       ERROR   :   Metadata:
frigate  | [2022-12-30 13:11:50] ffmpeg.*Camera2*.detect       ERROR   :     title           : IP Camera Video
frigate  | [2022-12-30 13:11:50] ffmpeg.*Camera2*.detect       ERROR   :     comment         : videoMain
frigate  | [2022-12-30 13:11:50] ffmpeg.*Camera2*.detect       ERROR   :   Duration: N/A, start: 0.000000, bitrate: N/A
frigate  | [2022-12-30 13:11:50] ffmpeg.*Camera2*.detect       ERROR   :   Stream #0:0: Video: h264 (Main), yuvj420p(pc, bt709, progressive), 3840x2160, 15 fps, 15 tbr, 90k tbn
frigate  | [2022-12-30 13:11:50] ffmpeg.*Camera2*.detect       ERROR   :   Stream #0:1: Data: none
frigate  | [2022-12-30 13:11:50] ffmpeg.*Camera2*.detect       ERROR   : [h264_cuvid @ 0x56497d11ba00] Cannot load libnvcuvid.so.1
frigate  | [2022-12-30 13:11:50] ffmpeg.*Camera2*.detect       ERROR   : [h264_cuvid @ 0x56497d11ba00] Failed loading nvcuvid.
frigate  | [2022-12-30 13:11:50] ffmpeg.*Camera2*.detect       ERROR   : Stream mapping:
frigate  | [2022-12-30 13:11:50] ffmpeg.*Camera2*.detect       ERROR   :   Stream #0:0 -> #0:0 (copy)
frigate  | [2022-12-30 13:11:50] ffmpeg.*Camera2*.detect       ERROR   :   Stream #0:0 -> #1:0 (copy)
frigate  | [2022-12-30 13:11:50] ffmpeg.*Camera2*.detect       ERROR   :   Stream #0:0 -> #2:0 (h264 (h264_cuvid) -> rawvideo (native))
frigate  | [2022-12-30 13:11:50] ffmpeg.*Camera2*.detect       ERROR   : Error while opening decoder for input stream #0:0 : Operation not permitted
frigate  | [2022-12-30 13:11:50] watchdog.*Camera3*            ERROR   : Ffmpeg process crashed unexpectedly for *Camera3*.
frigate  | [2022-12-30 13:11:50] watchdog.*Camera3*            ERROR   : The following ffmpeg logs include the last 100 lines prior to exit.
frigate  | [2022-12-30 13:11:50] ffmpeg.*Camera3*.detect       ERROR   : Guessed Channel Layout for Input Stream #0.1 : mono
frigate  | [2022-12-30 13:11:50] ffmpeg.*Camera3*.detect       ERROR   : Input #0, rtsp, from '*RTSP*':
frigate  | [2022-12-30 13:11:50] ffmpeg.*Camera3*.detect       ERROR   :   Metadata:
frigate  | [2022-12-30 13:11:50] ffmpeg.*Camera3*.detect       ERROR   :     title           : IP Camera Video
frigate  | [2022-12-30 13:11:50] ffmpeg.*Camera3*.detect       ERROR   :     comment         : videoMain
frigate  | [2022-12-30 13:11:50] ffmpeg.*Camera3*.detect       ERROR   :   Duration: N/A, start: 0.000000, bitrate: N/A
frigate  | [2022-12-30 13:11:50] ffmpeg.*Camera3*.detect       ERROR   :   Stream #0:0: Video: h264 (Baseline), yuv420p(progressive), 1920x1080, 24 fps, 24 tbr, 90k tbn
frigate  | [2022-12-30 13:11:50] ffmpeg.*Camera3*.detect       ERROR   :   Stream #0:1: Audio: pcm_mulaw, 8000 Hz, mono, s16, 64 kb/s
frigate  | [2022-12-30 13:11:50] ffmpeg.*Camera3*.detect       ERROR   : [h264_cuvid @ 0x55a1334415c0] Cannot load libnvcuvid.so.1
frigate  | [2022-12-30 13:11:50] ffmpeg.*Camera3*.detect       ERROR   : [h264_cuvid @ 0x55a1334415c0] Failed loading nvcuvid.
frigate  | [2022-12-30 13:11:50] ffmpeg.*Camera3*.detect       ERROR   : Stream mapping:
frigate  | [2022-12-30 13:11:50] ffmpeg.*Camera3*.detect       ERROR   :   Stream #0:0 -> #0:0 (copy)
frigate  | [2022-12-30 13:11:50] ffmpeg.*Camera3*.detect       ERROR   :   Stream #0:1 -> #0:1 (pcm_mulaw (native) -> aac (native))
frigate  | [2022-12-30 13:11:50] ffmpeg.*Camera3*.detect       ERROR   :   Stream #0:0 -> #1:0 (copy)
frigate  | [2022-12-30 13:11:50] ffmpeg.*Camera3*.detect       ERROR   :   Stream #0:1 -> #1:1 (copy)
frigate  | [2022-12-30 13:11:50] ffmpeg.*Camera3*.detect       ERROR   :   Stream #0:0 -> #2:0 (h264 (h264_cuvid) -> rawvideo (native))
frigate  | [2022-12-30 13:11:50] ffmpeg.*Camera3*.detect       ERROR   : Error while opening decoder for input stream #0:0 : Operation not permitted
frigate  | [2022-12-30 13:11:50] watchdog.*Camera6*              ERROR   : Ffmpeg process crashed unexpectedly for *Camera6*.
frigate  | [2022-12-30 13:11:50] watchdog.*Camera6*              ERROR   : The following ffmpeg logs include the last 100 lines prior to exit.
frigate  | [2022-12-30 13:11:50] ffmpeg.*Camera6*.detect         ERROR   : Guessed Channel Layout for Input Stream #0.1 : mono
frigate  | [2022-12-30 13:11:50] ffmpeg.*Camera6*.detect         ERROR   : Input #0, rtsp, from '*RTSP*':
frigate  | [2022-12-30 13:11:50] ffmpeg.*Camera6*.detect         ERROR   :   Metadata:
frigate  | [2022-12-30 13:11:50] ffmpeg.*Camera6*.detect         ERROR   :     title           : IP Camera Video
frigate  | [2022-12-30 13:11:50] ffmpeg.*Camera6*.detect         ERROR   :     comment         : videoMain
frigate  | [2022-12-30 13:11:50] ffmpeg.*Camera6*.detect         ERROR   :   Duration: N/A, start: 0.000000, bitrate: N/A
frigate  | [2022-12-30 13:11:50] ffmpeg.*Camera6*.detect         ERROR   :   Stream #0:0: Video: h264 (Baseline), yuv420p(progressive), 1920x1080, 25 fps, 25 tbr, 90k tbn
frigate  | [2022-12-30 13:11:50] ffmpeg.*Camera6*.detect         ERROR   :   Stream #0:1: Audio: pcm_mulaw, 8000 Hz, mono, s16, 64 kb/s
frigate  | [2022-12-30 13:11:50] ffmpeg.*Camera6*.detect         ERROR   : [h264_cuvid @ 0x55768edba5c0] Cannot load libnvcuvid.so.1
frigate  | [2022-12-30 13:11:50] ffmpeg.*Camera6*.detect         ERROR   : [h264_cuvid @ 0x55768edba5c0] Failed loading nvcuvid.
frigate  | [2022-12-30 13:11:50] ffmpeg.*Camera6*.detect         ERROR   : Stream mapping:
frigate  | [2022-12-30 13:11:50] ffmpeg.*Camera6*.detect         ERROR   :   Stream #0:0 -> #0:0 (copy)
frigate  | [2022-12-30 13:11:50] ffmpeg.*Camera6*.detect         ERROR   :   Stream #0:0 -> #1:0 (copy)
frigate  | [2022-12-30 13:11:50] ffmpeg.*Camera6*.detect         ERROR   :   Stream #0:1 -> #1:1 (copy)
frigate  | [2022-12-30 13:11:50] ffmpeg.*Camera6*.detect         ERROR   :   Stream #0:0 -> #2:0 (h264 (h264_cuvid) -> rawvideo (native))
frigate  | [2022-12-30 13:11:50] ffmpeg.*Camera6*.detect         ERROR   : Error while opening decoder for input stream #0:0 : Operation not permitted
frigate  | [2022-12-30 13:11:50] watchdog.*Camera5*              ERROR   : Ffmpeg process crashed unexpectedly for *Camera5*.
frigate  | [2022-12-30 13:11:50] watchdog.*Camera5*              ERROR   : The following ffmpeg logs include the last 100 lines prior to exit.
frigate  | [2022-12-30 13:11:50] ffmpeg.*Camera5*.detect         ERROR   : Guessed Channel Layout for Input Stream #0.1 : mono
frigate  | [2022-12-30 13:11:50] ffmpeg.*Camera5*.detect         ERROR   : Input #0, rtsp, from '*RTSP*':
frigate  | [2022-12-30 13:11:50] ffmpeg.*Camera5*.detect         ERROR   :   Metadata:
frigate  | [2022-12-30 13:11:50] ffmpeg.*Camera5*.detect         ERROR   :     title           : IP Camera Video
frigate  | [2022-12-30 13:11:50] ffmpeg.*Camera5*.detect         ERROR   :     comment         : videoMain
frigate  | [2022-12-30 13:11:50] ffmpeg.*Camera5*.detect         ERROR   :   Duration: N/A, start: 0.000000, bitrate: N/A
frigate  | [2022-12-30 13:11:50] ffmpeg.*Camera5*.detect         ERROR   :   Stream #0:0: Video: h264 (Baseline), yuv420p(progressive), 1920x1080, 25 fps, 25 tbr, 90k tbn
frigate  | [2022-12-30 13:11:50] ffmpeg.*Camera5*.detect         ERROR   :   Stream #0:1: Audio: pcm_mulaw, 8000 Hz, mono, s16, 64 kb/s
frigate  | [2022-12-30 13:11:50] ffmpeg.*Camera5*.detect         ERROR   : [h264_cuvid @ 0x5607157af5c0] Cannot load libnvcuvid.so.1
frigate  | [2022-12-30 13:11:50] ffmpeg.*Camera5*.detect         ERROR   : [h264_cuvid @ 0x5607157af5c0] Failed loading nvcuvid.
frigate  | [2022-12-30 13:11:50] ffmpeg.*Camera5*.detect         ERROR   : Stream mapping:
frigate  | [2022-12-30 13:11:50] ffmpeg.*Camera5*.detect         ERROR   :   Stream #0:0 -> #0:0 (copy)
frigate  | [2022-12-30 13:11:50] ffmpeg.*Camera5*.detect         ERROR   :   Stream #0:0 -> #1:0 (copy)
frigate  | [2022-12-30 13:11:50] ffmpeg.*Camera5*.detect         ERROR   :   Stream #0:1 -> #1:1 (copy)
frigate  | [2022-12-30 13:11:50] ffmpeg.*Camera5*.detect         ERROR   :   Stream #0:0 -> #2:0 (h264 (h264_cuvid) -> rawvideo (native))
frigate  | [2022-12-30 13:11:50] ffmpeg.*Camera5*.detect         ERROR   : Error while opening decoder for input stream #0:0 : Operation not permitted
frigate  | [2022-12-30 13:11:50] watchdog.*Camera7*         ERROR   : Ffmpeg process crashed unexpectedly for *Camera7*.
frigate  | [2022-12-30 13:11:50] watchdog.*Camera7*         ERROR   : The following ffmpeg logs include the last 100 lines prior to exit.
frigate  | [2022-12-30 13:11:50] ffmpeg.*Camera7*.detect    ERROR   : Input #0, rtsp, from '*RTSP*':
frigate  | [2022-12-30 13:11:50] ffmpeg.*Camera7*.detect    ERROR   :   Metadata:
frigate  | [2022-12-30 13:11:50] ffmpeg.*Camera7*.detect    ERROR   :     title           : IP Camera Video
frigate  | [2022-12-30 13:11:50] ffmpeg.*Camera7*.detect    ERROR   :     comment         : videoMain
frigate  | [2022-12-30 13:11:50] ffmpeg.*Camera7*.detect    ERROR   :   Duration: N/A, start: 0.000000, bitrate: N/A
frigate  | [2022-12-30 13:11:50] ffmpeg.*Camera7*.detect    ERROR   :   Stream #0:0: Video: h264 (Main), yuv420p(progressive), 1280x720, 25 fps, 25 tbr, 90k tbn
frigate  | [2022-12-30 13:11:50] ffmpeg.*Camera7*.detect    ERROR   :   Stream #0:1: Audio: pcm_mulaw, 8000 Hz, mono, s16, 64 kb/s
frigate  | [2022-12-30 13:11:50] ffmpeg.*Camera7*.detect    ERROR   : [h264_cuvid @ 0x55e8e2a46c80] Cannot load libnvcuvid.so.1
frigate  | [2022-12-30 13:11:50] ffmpeg.*Camera7*.detect    ERROR   : [h264_cuvid @ 0x55e8e2a46c80] Failed loading nvcuvid.
frigate  | [2022-12-30 13:11:50] ffmpeg.*Camera7*.detect    ERROR   : Stream mapping:
frigate  | [2022-12-30 13:11:50] ffmpeg.*Camera7*.detect    ERROR   :   Stream #0:0 -> #0:0 (copy)
frigate  | [2022-12-30 13:11:50] ffmpeg.*Camera7*.detect    ERROR   :   Stream #0:1 -> #0:1 (pcm_mulaw (native) -> aac (native))
frigate  | [2022-12-30 13:11:50] ffmpeg.*Camera7*.detect    ERROR   :   Stream #0:0 -> #1:0 (copy)
frigate  | [2022-12-30 13:11:50] ffmpeg.*Camera7*.detect    ERROR   :   Stream #0:1 -> #1:1 (copy)
frigate  | [2022-12-30 13:11:50] ffmpeg.*Camera7*.detect    ERROR   :   Stream #0:0 -> #2:0 (h264 (h264_cuvid) -> rawvideo (native))
frigate  | [2022-12-30 13:11:50] ffmpeg.*Camera7*.detect    ERROR   : Error while opening decoder for input stream #0:0 : Operation not permitted
frigate  | [2022-12-30 13:11:50] watchdog.*Camera1*         ERROR   : Ffmpeg process crashed unexpectedly for *Camera1*.
frigate  | [2022-12-30 13:11:50] watchdog.*Camera1*         ERROR   : The following ffmpeg logs include the last 100 lines prior to exit.
frigate  | [2022-12-30 13:11:50] ffmpeg.*Camera1*.detect    ERROR   : Input #0, rtsp, from '*RTSP*':
frigate  | [2022-12-30 13:11:50] ffmpeg.*Camera1*.detect    ERROR   :   Metadata:
frigate  | [2022-12-30 13:11:50] ffmpeg.*Camera1*.detect    ERROR   :     title           : IP Camera Video
frigate  | [2022-12-30 13:11:50] ffmpeg.*Camera1*.detect    ERROR   :     comment         : videoMain
frigate  | [2022-12-30 13:11:50] ffmpeg.*Camera1*.detect    ERROR   :   Duration: N/A, start: 0.000000, bitrate: N/A
frigate  | [2022-12-30 13:11:50] ffmpeg.*Camera1*.detect    ERROR   :   Stream #0:0: Video: h264 (Main), yuv420p(progressive), 1280x720, 25 fps, 25 tbr, 90k tbn
frigate  | [2022-12-30 13:11:50] ffmpeg.*Camera1*.detect    ERROR   :   Stream #0:1: Audio: pcm_mulaw, 8000 Hz, mono, s16, 64 kb/s
frigate  | [2022-12-30 13:11:50] ffmpeg.*Camera1*.detect    ERROR   : [h264_cuvid @ 0x55c95f255300] Cannot load libnvcuvid.so.1
frigate  | [2022-12-30 13:11:50] ffmpeg.*Camera1*.detect    ERROR   : [h264_cuvid @ 0x55c95f255300] Failed loading nvcuvid.
frigate  | [2022-12-30 13:11:50] ffmpeg.*Camera1*.detect    ERROR   : Stream mapping:
frigate  | [2022-12-30 13:11:50] ffmpeg.*Camera1*.detect    ERROR   :   Stream #0:0 -> #0:0 (copy)
frigate  | [2022-12-30 13:11:50] ffmpeg.*Camera1*.detect    ERROR   :   Stream #0:1 -> #0:1 (pcm_mulaw (native) -> aac (native))
frigate  | [2022-12-30 13:11:50] ffmpeg.*Camera1*.detect    ERROR   :   Stream #0:0 -> #1:0 (copy)
frigate  | [2022-12-30 13:11:50] ffmpeg.*Camera1*.detect    ERROR   :   Stream #0:1 -> #1:1 (copy)
frigate  | [2022-12-30 13:11:50] ffmpeg.*Camera1*.detect    ERROR   :   Stream #0:0 -> #2:0 (h264 (h264_cuvid) -> rawvideo (native))
frigate  | [2022-12-30 13:11:50] ffmpeg.*Camera1*.detect    ERROR   : Error while opening decoder for input stream #0:0 : Operation not permitted
frigate  | [2022-12-30 13:11:51] frigate.video                  ERROR   : *Camera1*: Unable to read frames from ffmpeg process.
frigate  | [2022-12-30 13:11:51] frigate.video                  ERROR   : *Camera1*: ffmpeg process is not running. exiting capture thread...
frigate  | [2022-12-30 13:11:51] frigate.video                  ERROR   : *Camera7*: Unable to read frames from ffmpeg process.
frigate  | [2022-12-30 13:11:51] frigate.video                  ERROR   : *Camera7*: ffmpeg process is not running. exiting capture thread...
frigate  | [2022-12-30 13:11:51] frigate.video                  ERROR   : *Camera4*: Unable to read frames from ffmpeg process.
frigate  | [2022-12-30 13:11:51] frigate.video                  ERROR   : *Camera4*: ffmpeg process is not running. exiting capture thread...
frigate  | [2022-12-30 13:11:51] frigate.video                  ERROR   : *Camera5*: Unable to read frames from ffmpeg process.
frigate  | [2022-12-30 13:11:51] frigate.video                  ERROR   : *Camera5*: ffmpeg process is not running. exiting capture thread...
frigate  | [2022-12-30 13:11:51] frigate.video                  ERROR   : *Camera6*: Unable to read frames from ffmpeg process.
frigate  | [2022-12-30 13:11:51] frigate.video                  ERROR   : *Camera6*: ffmpeg process is not running. exiting capture thread...
frigate  | [2022-12-30 13:11:51] frigate.video                  ERROR   : *Camera3*: Unable to read frames from ffmpeg process.
frigate  | [2022-12-30 13:11:51] frigate.video                  ERROR   : *Camera3*: ffmpeg process is not running. exiting capture thread...

FFprobe output from your camera

*IRRELEVANT*

Operating system

Debian

Install method

Docker Compose

Network connection

Wired

Camera make and model

IRRELEVANT

Any other information that may be helpful

I believe the documentation is either outdated, or the ffmpeg support is broken. Either way, it is not clear how to make nVidia hw accel work.

LukasMojzis avatar Dec 30 '22 12:12 LukasMojzis

It's not that simple, installing the nvidia driver on your host will have entirely different instructions based on what your host OS is. For example I run an nvidia GPU with Unraid and that has a plugin downloaded from the community store meanwhile on Debian the instructions would be different.

Nvidia hwaccel is working as expected in 0.11, any missing libraries need to be installed on the host for it to work in frigate.

NickM-27 avatar Dec 30 '22 13:12 NickM-27

You can see https://github.com/blakeblackshear/frigate/issues/3619#issuecomment-1209564760 where a similar issue with the host os was resolved.

NickM-27 avatar Dec 30 '22 13:12 NickM-27

I have already seen that one. I have added the official nVidia repo, but I do not see any nvidia-*decode packages. These are the ones I already installed:

# apt list --installed | grep nvidia | grep -v automatic

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

nvidia-container-runtime/buster,now 3.11.0-1 all [installed]
nvidia-container-toolkit/buster,now 1.11.0-1 amd64 [installed]
nvidia-cuda-toolkit/stable,now 11.2.2-3+deb11u3 amd64 [installed]
nvidia-detect/now 470.141.03-1~deb11u1 amd64 [installed,upgradable to: 470.161.03-1]
nvidia-docker2/buster,now 2.11.0-1 all [installed]
nvidia-driver-libs/stable,now 470.161.03-1 amd64 [installed]
nvidia-driver/stable,now 470.161.03-1 amd64 [installed]
nvidia-egl-common/now 470.141.03-1~deb11u1 amd64 [installed,upgradable to: 470.161.03-1]
nvidia-legacy-check/now 470.141.03-1~deb11u1 amd64 [installed,upgradable to: 470.161.03-1]
nvidia-smi/stable,now 470.161.03-1 amd64 [installed]

LukasMojzis avatar Dec 31 '22 02:12 LukasMojzis

Looks like a similar issue here https://github.com/NVIDIA/nvidia-docker/issues/1001#issuecomment-507046741 and here https://github.com/NVIDIA/nvidia-docker/issues/1587#issuecomment-1008618542

It's going to be something that hasn't been installed or isn't in the right place on the host OS.

NickM-27 avatar Dec 31 '22 02:12 NickM-27

I have retried to install the nvidia-driver-bin instead of nvidia-driver from the cuda repository. Somehow it pulled even newer driver.

# apt list --installed | grep nvidia | grep -v automatic

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

libnvidia-egl-wayland1/stable,now 1:1.1.5-1 amd64 [installed,auto-removable]
libnvidia-encode1/unknown,now 525.60.13-1 amd64 [installed]
nvidia-container-runtime/buster,now 3.11.0-1 all [installed]
nvidia-container-toolkit/buster,now 1.11.0-1 amd64 [installed]
nvidia-cuda-toolkit/stable,now 11.2.2-3+deb11u3 amd64 [installed]
nvidia-detect/now 470.141.03-1~deb11u1 amd64 [installed,upgradable to: 525.60.13-1]
nvidia-docker2/buster,now 2.11.0-1 all [installed]
nvidia-driver-libs/unknown,now 525.60.13-1 amd64 [installed]
nvidia-driver/unknown,now 525.60.13-1 amd64 [installed]
nvidia-egl-common/now 470.141.03-1~deb11u1 amd64 [installed,upgradable to: 525.60.13-1]
nvidia-legacy-check/now 470.141.03-1~deb11u1 amd64 [installed,upgradable to: 525.60.13-1]
nvidia-modprobe/stable,now 470.103.01-1~deb11u1 amd64 [installed,upgradable to: 525.60.13-1]
nvidia-smi/unknown,now 525.60.13-1 amd64 [installed]

I was then able to verify those links exist in the system from the install process:

# ls -lah /usr/lib/x86_64-linux-gnu/libnvcuvid.so.1 /usr/lib/x86_64-linux-gnu/libnvcuvid.so 
lrwxrwxrwx 1 root root 56 Dec 31 03:52 /usr/lib/x86_64-linux-gnu/libnvcuvid.so -> /etc/alternatives/nvidia--libnvcuvid.so-x86_64-linux-gnu
lrwxrwxrwx 1 root root 58 Dec 31 03:52 /usr/lib/x86_64-linux-gnu/libnvcuvid.so.1 -> /etc/alternatives/nvidia--libnvcuvid.so.1-x86_64-linux-gnu

however the second symlink did not exist:

# ls -lah /usr/lib/x86_64-linux-gnu/libnvidia-encode.so.1 /usr/lib/x86_64-linux-gnu/libnvidia-encode.so
ls: cannot access '/usr/lib/x86_64-linux-gnu/libnvidia-encode.so': No such file or directory
lrwxrwxrwx 1 root root 64 Dec 31 03:52 /usr/lib/x86_64-linux-gnu/libnvidia-encode.so.1 -> /etc/alternatives/nvidia--libnvidia-encode.so.1-x86_64-linux-gnu

so I recreated it with the ln -s from the aforementioned comment

# ls -lah /usr/lib/x86_64-linux-gnu/libnvidia-encode.so.1 /usr/lib/x86_64-linux-gnu/libnvidia-encode.so
lrwxrwxrwx 1 root root 47 Dec 31 04:06 /usr/lib/x86_64-linux-gnu/libnvidia-encode.so -> /usr/lib/x86_64-linux-gnu/libnvidia-encode.so.1
lrwxrwxrwx 1 root root 64 Dec 31 03:52 /usr/lib/x86_64-linux-gnu/libnvidia-encode.so.1 -> /etc/alternatives/nvidia--libnvidia-encode.so.1-x86_64-linux-gnu

restarted docker and the status was still the same. Finally I just mounted the libs to the container and the error changed from libnvcuvid missing to libcuda missing to

ERROR   : [AVHWDeviceContext @ 0x558e3e2cf200] cu->cuInit(0) failed -> CUDA_ERROR_UNKNOWN: unknown error

but when I wanted to try if nvidia-smi still works I found the following when installing:

update-alternatives: warning: forcing reinstallation of alternative /usr/lib/nvidia/current because link group nvidia is broken
update-alternatives: warning: not replacing /usr/lib/x86_64-linux-gnu/libcuda.so.1 with a link
update-alternatives: warning: not replacing /usr/lib/x86_64-linux-gnu/libnvcuvid.so.1 with a link
update-alternatives: warning: forcing reinstallation of alternative /usr/lib/nvidia/current because link group nvidia is broken
update-alternatives: warning: not replacing /usr/lib/x86_64-linux-gnu/libcuda.so.1 with a link
update-alternatives: warning: not replacing /usr/lib/x86_64-linux-gnu/libnvcuvid.so.1 with a link

so i reversed the mounting and tried installing without it. The libs were now present in the container itself:

root@a4522826c922:/opt/frigate# ldconfig -p | grep cuvid
        libnvcuvid.so.1 (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/libnvcuvid.so.1
        libnvcuvid.so (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/libnvcuvid.so
root@a4522826c922:/opt/frigate# ldconfig -p | grep cuda 
        libicudata.so.67 (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/libicudata.so.67
        libcuda.so.1 (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/libcuda.so.1
        libcuda.so (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/libcuda.so

Upon restarting the container I found the HW Accel is working:

# nvidia-smi
Sat Dec 31 04:37:20 2022       
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 525.60.13    Driver Version: 525.60.13    CUDA Version: 12.0     |
|-------------------------------+----------------------+----------------------+
| 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:01:00.0 Off |                  N/A |
| 20%   37C    P0    N/A /  N/A |    914MiB /  4096MiB |     21%      Default |
|                               |                      |                  N/A |
+-------------------------------+----------------------+----------------------+
                                                                               
+-----------------------------------------------------------------------------+
| Processes:                                                                  |
|  GPU   GI   CI        PID   Type   Process name                  GPU Memory |
|        ID   ID                                                   Usage      |
|=============================================================================|
|    0   N/A  N/A     48678      C   ffmpeg                            343MiB |
|    0   N/A  N/A     48679      C   ffmpeg                            103MiB |
|    0   N/A  N/A     48686      C   ffmpeg                            103MiB |
|    0   N/A  N/A     48696      C   ffmpeg                            103MiB |
|    0   N/A  N/A     48697      C   ffmpeg                            103MiB |
|    0   N/A  N/A     48701      C   ffmpeg                             76MiB |
|    0   N/A  N/A     48704      C   ffmpeg                             76MiB |
+-----------------------------------------------------------------------------+

but no docs mention the need to install drivers INSIDE. After a little bit of diffing the docker-compose.yml i found a suspicious looking env vars NVIDIA_VISIBLE_DEVICES and NVIDIA_DRIVER_CAPABILITIES

    environment:
      FRIGATE_RTSP_PASSWORD: *REDACTED*
      PLUS_API_KEY: *REDACTED*
      NVIDIA_VISIBLE_DEVICES: all
#      NVIDIA_DRIVER_CAPABILITIES: compute,utility,video ## turned out to be unnecessary

and voilà - the ffmpeg works now.

I will add another comment w/ documentation amendment proposal below

LukasMojzis avatar Dec 31 '22 03:12 LukasMojzis

I propose adding the crucial env vars to frigate docker-compose.yml section of the documentation so it reads

services:
  frigate:
    ...
    image: blakeblackshear/frigate:stable
    environment:
      NVIDIA_VISIBLE_DEVICES: all # add this variable as well (or adjust it as needed when you have multiple GPUs)
      NVIDIA_DRIVER_CAPABILITIES: compute,utility,video # probably not needed

because it works even without the deploy stanza.

LukasMojzis avatar Dec 31 '22 03:12 LukasMojzis

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

github-actions[bot] avatar Jan 31 '23 00:01 github-actions[bot]