frigate: AMD Ryzen hardware acceleration not supported

Describe the bug A lot of the AMD Ryzen APUs have an integrated GPU that can be used to accelerate video.

Usually I would have expected to use this env far: LIBVA_DRIVER_NAME=radeonsi

But it turns out, the container doesn’t have it which causes ffmpeg to crash:

root@edd635788772:/opt/frigate# ls /usr/lib/x86_64-linux-gnu/dri/
i965_drv_video.so
iHD_drv_video.so

On my host system you can see the radeonsi drivers:

$ ls -lash /usr/lib64/dri/
total 243M
   0 drwxr-xr-x 1 root root  424 Nov 22 19:23 .
   0 drwxr-xr-x 1 root root  37K Nov 24 13:14 ..
 14M -rwxr-xr-x 4 root root  14M Nov 12 14:07 i915_dri.so
 14M -rwxr-xr-x 4 root root  14M Nov 12 14:07 i965_dri.so
 21M -rwxr-xr-x 8 root root  21M Nov 12 14:07 iris_dri.so
 21M -rwxr-xr-x 8 root root  21M Nov 12 14:07 kms_swrast_dri.so
9.0M -rwxr-xr-x 3 root root 8.9M Nov 12 14:07 nouveau_drv_video.so
 14M -rwxr-xr-x 4 root root  14M Nov 12 14:07 r200_dri.so
 21M -rwxr-xr-x 8 root root  21M Nov 12 14:07 r300_dri.so
 21M -rwxr-xr-x 8 root root  21M Nov 12 14:07 r600_dri.so
9.0M -rwxr-xr-x 3 root root 8.9M Nov 12 14:07 r600_drv_video.so
 14M -rwxr-xr-x 4 root root  14M Nov 12 14:07 radeon_dri.so
 21M -rwxr-xr-x 8 root root  21M Nov 12 14:07 radeonsi_dri.so
9.0M -rwxr-xr-x 3 root root 8.9M Nov 12 14:07 radeonsi_drv_video.so
 21M -rwxr-xr-x 8 root root  21M Nov 12 14:07 swrast_dri.so
 21M -rwxr-xr-x 8 root root  21M Nov 12 14:07 virtio_gpu_dri.so
 21M -rwxr-xr-x 8 root root  21M Nov 12 14:07 vmwgfx_dri.so

This is where they come from:

$ rpm -q --whatprovides /usr/lib64/dri/radeon*
Mesa-dri-20.2.2-266.1.x86_64
Mesa-dri-20.2.2-266.1.x86_64
Mesa-libva-20.2.2-266.1.x86_64

I can successfully encode:

ffmpeg -i input.mp4 -vaapi_device /dev/dri/renderD128 -vcodec h264_vaapi -vf format='nv12|vaapi,hwupload' output.mp4

or decode:

ffmpeg -hwaccel vaapi -hwaccel_device /dev/dri/renderD128 -i rtsp://192.168.30.176/live0 derp.mp4

I forwarded /dev/dri/ to the container.

Version of frigate latest docker

Config file Include your full config file wrapped in triple back ticks.

  hwaccel_args:
    - -hwaccel
    - vaapi
    - -hwaccel_device
    - /dev/dri/renderD128

Computer Hardware

  • OS: openSUSE Tumbleweed
  • CPU/GPU: AMD Ryzen 3400g
  • Virtualization: nope
  • Coral Version: USB
  • Network Setup: Wired

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 19 (8 by maintainers)

Commits related to this issue

Most upvoted comments

@y2kdread looks like you are not running frigate 0.12, you are probably on 0.11.

There’s not a lot that you have to do:

  1. Set ffmpeg
ffmpeg:
  hwaccel_args: preset-vaapi
  1. Make sure your docker container has device /dev/dri/renderD128 forwarded (and that it exists on your system)
  2. Set LIBVA_DRIVER_NAME environment variable for your docker to ‘radeonsi’

So installing that driver and setting the env var is all you need? Should be easy enough to add the driver to the build.