Skip to content

[HW Accel Support]: High CPU and zero iGPU usage with hardware acceleration #8904

Description

@albertomercurio

Describe the problem you are having

I have two cameras that stream h264 rtsp. My system has an Intel N95, and I want to use the hardware acceleration. In my docker compose file, I also added the /dev/dri/card0 device, because when I run intel_gpu_top this is my output

intel-gpu-top: 8086:46d2 @ /dev/dri/card0 -  455/ 805 MHz;   0% RC6;      105 irqs/s

         ENGINES     BUSY                                                                                                                             MI_SEMA MI_WAIT
       Render/3D    0.69% |▉                                                                                                                        |      0%      0%
         Blitter    0.00% |                                                                                                                         |      0%      0%
           Video    0.66% |▉                                                                                                                        |      0%      0%
    VideoEnhance    0.00% |                                                                                                                         |      0%      0%

But maybe it is not important.

Although I set the vaapi hardware acceleration, I see that the cpu usage is very high (70% or higher), while the iGPU usage is almost zero (you can see in the example I showed above).

I tried to use also the QuickSync acceleration, but it doesn't work. I get and error and I can't see anything.

Version

0.12.1-367D724

Frigate config file

mqtt:
  enabled: false # I don't use Home Assistant automations for the moment

database:
  # The path to store the SQLite DB (default: shown below)
  path: /db/frigate.db

detectors:
  cpu:
    type: cpu
    num_threads: 4

ffmpeg:
  hwaccel_args: preset-vaapi
  # hwaccel_args: preset-intel-qsv-h264

go2rtc:
  streams:
    garage:
      - rtsp://192.168.1.27:8554/mainstream
    garage_sub:
      - rtsp://192.168.1.27:8554/substream
    cucina:
      - rtsp://192.168.1.24:8554/mainstream
    cucina_sub:
      - rtsp://192.168.1.24:8554/substream


objects:
  track:
    - person
  filters:
    person:
      threshold: 0.7


cameras:
  garage:
    ffmpeg:
      inputs:
        - path: rtsp://127.0.0.1:8554/garage_sub
          roles:
            - detect
        - path: rtsp://127.0.0.1:8554/garage
          roles:
            - record
    detect:
      enabled: true
      width: 720
      height: 480
    record:
      enabled: true
  cucina:
    ffmpeg:
      inputs:
        - path: rtsp://127.0.0.1:8554/cucina_sub
          roles:
            - detect
        - path: rtsp://127.0.0.1:8554/cucina
          roles:
            - record
    detect:
      enabled: true
      width: 720
      height: 480
    record:
      enabled: true

docker-compose file or Docker CLI command

frigate:
    container_name: frigate
    privileged: true # this may not be necessary for all setups
    restart: unless-stopped
    image: ghcr.io/blakeblackshear/frigate:stable
    shm_size: "128mb" # update for your cameras based on calculation above
    networks:
      - casanetwork
    devices:
      - /dev/bus/usb:/dev/bus/usb # passes the USB Coral, needs to be modified for other versions
      # - /dev/apex_0:/dev/apex_0 # passes a PCIe Coral, follow driver instructions here https://coral.ai/docs/m2/get-started/#2a-on-linux
      - /dev/dri/renderD128 # for intel hwaccel, needs to be updated for your hardware
      - /dev/dri/card0 # for intel hwaccel, needs to be updated for your hardware
    volumes:
      - /etc/localtime:/etc/localtime:ro
      - /home/casa/docker-compose/frigate/config/config.yml:/config/config.yml
      - /home/casa/frigate/media:/media/frigate # Not in the docker-compose folder because it might be too big
      - /home/casa/docker-compose/frigate/db:/db
      - type: tmpfs # Optional: 1GB of memory, reduces SSD/SD Card wear
        target: /tmp/cache
        tmpfs:
          size: 1000000000
    ports:
      - "5000:5000"
      - "8554:8554" # RTSP feeds
      - "8555:8555/tcp" # WebRTC over tcp
      - "8555:8555/udp" # WebRTC over udp

Relevant log output

2023-12-09 12:31:25.006702637  [INFO] Starting Frigate...
2023-12-09 12:31:25.931149409  [2023-12-09 12:31:25] frigate.app                    INFO    : Starting Frigate (0.12.1-367d724)
2023-12-09 12:31:25.948883481  [2023-12-09 12:31:25] peewee_migrate                 INFO    : Starting migrations
2023-12-09 12:31:25.952658066  [2023-12-09 12:31:25] peewee_migrate                 INFO    : There is nothing to migrate
2023-12-09 12:31:25.965941836  [2023-12-09 12:31:25] detector.cpu                   INFO    : Starting detection process: 289
2023-12-09 12:31:25.968958572  [2023-12-09 12:31:25] frigate.app                    INFO    : Output process started: 291
2023-12-09 12:31:25.969169287  [2023-12-09 12:31:25] frigate.detectors              WARNING : CPU detectors are not recommended and should only be used for testing or for trial purposes.
2023-12-09 12:31:25.976120795  [2023-12-09 12:31:25] frigate.app                    INFO    : Camera processor started for garage: 294
2023-12-09 12:31:25.982416023  [2023-12-09 12:31:25] frigate.app                    INFO    : Camera processor started for cucina: 296
2023-12-09 12:31:25.988026156  [2023-12-09 12:31:25] frigate.app                    INFO    : Capture process started for garage: 297
2023-12-09 12:31:25.994569349  [2023-12-09 12:31:25] frigate.app                    INFO    : Capture process started for cucina: 301

FFprobe output from your camera

ffprobe version 4.4.2-0ubuntu0.22.04.1 Copyright (c) 2007-2021 the FFmpeg developers
  built with gcc 11 (Ubuntu 11.2.0-19ubuntu1)
  configuration: --prefix=/usr --extra-version=0ubuntu0.22.04.1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libdav1d --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librabbitmq --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzimg --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-pocketsphinx --enable-librsvg --enable-libmfx --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared
  libavutil      56. 70.100 / 56. 70.100
  libavcodec     58.134.100 / 58.134.100
  libavformat    58. 76.100 / 58. 76.100
  libavdevice    58. 13.100 / 58. 13.100
  libavfilter     7.110.100 /  7.110.100
  libswscale      5.  9.100 /  5.  9.100
  libswresample   3.  9.100 /  3.  9.100
  libpostproc    55.  9.100 / 55.  9.100
Input #0, rtsp, from 'rtsp://192.168.1.24:8554/substream':
  Metadata:
    title           : 
    comment         : substream
  Duration: N/A, start: 0.040000, bitrate: N/A
  Stream #0:0: Video: h264 (Constrained Baseline), yuvj420p(pc, progressive), 640x360, 25 fps, 25 tbr, 90k tbn, 180k tbc

Operating system

Other

Install method

Docker Compose

Network connection

Wired

Camera make and model

Hacked Xiaomi 360

Any other information that may be helpful

My system has Ubuntu 22.04

The Hacked firmware of my camera is available at this link

https://github.com/telmomarques/xiaomi-360-1080p-hacks

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions