Jump to content

Hardware acceleration by using Docker


Rdlop
Go to solution Solved by Rdlop,

Recommended Posts

I'd like to add hardware acceleration for my Orange PI 5 Plus, i've installed  ` apt install -y clinfo` on the host (armbian)


 


docker exec -it jellyfin /usr/lib/jellyfin-ffmpeg/ffmpeg -v debug -init_hw_device rkmpp=rk -init_hw_device opencl=ocl@rk
ffmpeg version 6.0.1-Jellyfin Copyright (c) 2000-2023 the FFmpeg developers
  built with gcc 12 (Debian 12.2.0-14)
  configuration: --prefix=/usr/lib/jellyfin-ffmpeg --target-os=linux --extra-version=Jellyfin --disable-doc --disable-ffplay --disable-ptx-compression --disable-static --disable-libxcb --disable-sdl2 --disable-xlib --enable-lto --enable-gpl --enable-version3 --enable-shared --enable-gmp --enable-gnutls --enable-chromaprint --enable-opencl --enable-libdrm --enable-libxml2 --enable-libass --enable-libfreetype --enable-libfribidi --enable-libfontconfig --enable-libbluray --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvorbis --enable-libopenmpt --enable-libdav1d --enable-libsvtav1 --enable-libwebp --enable-libvpx --enable-libx264 --enable-libx265 --enable-libzvbi --enable-libzimg --enable-libfdk-aac --arch=arm64 --cross-prefix=/usr/bin/aarch64-linux-gnu- --toolchain=hardened --enable-cross-compile --enable-rkmpp --enable-rkrga
  libavutil      58.  2.100 / 58.  2.100
  libavcodec     60.  3.100 / 60.  3.100
  libavformat    60.  3.100 / 60.  3.100
  libavdevice    60.  1.100 / 60.  1.100
  libavfilter     9.  3.100 /  9.  3.100
  libswscale      7.  1.100 /  7.  1.100
  libswresample   4. 10.100 /  4. 10.100
  libpostproc    57.  1.100 / 57.  1.100
Splitting the commandline.
Reading option '-v' ... matched as option 'v' (set logging level) with argument 'debug'.
Reading option '-init_hw_device' ... matched as option 'init_hw_device' (initialise hardware device) with argument 'rkmpp=rk'.
Reading option '-init_hw_device' ... matched as option 'init_hw_device' (initialise hardware device) with argument 'opencl=ocl@rk'.
Finished splitting the commandline.
Parsing a group of options: global .
Applying option v (set logging level) with argument debug.
Applying option init_hw_device (initialise hardware device) with argument rkmpp=rk.
Applying option init_hw_device (initialise hardware device) with argument opencl=ocl@rk.
arm_release_ver: g13p0-01eac0, rk_so_ver: 10
Failed creating base context during opening of kernel driver.
Kernel module may not have been loaded
[AVHWDeviceContext @ 0xaaaadce49f00] 1 OpenCL platforms found.
[AVHWDeviceContext @ 0xaaaadce49f00] 1 OpenCL devices found on platform "ARM Platform".
arm_release_ver: g13p0-01eac0, rk_so_ver: 10
Failed creating base context during opening of kernel driver.
Kernel module may not have been loaded
[AVHWDeviceContext @ 0xaaaadce49f00] 0.0: ARM Platform / Unknown Device

exit code is 139 and device is unknown

 

Is there any package to install ?

Edited by Rdlop
Link to comment
Share on other sites

Armbian & Khadas are rewarding contributors

To use the rkmpp service you must be using a vendor based kernel (6.1.xx is recommended) - using armbianmonitor would identify that. Alternatively

 

$ ls -l /dev/mpp_service 
crw-rw---- 1 root video 241, 0 Sep  9 21:43 /dev/mpp_service
$ uname -a
Linux t6 6.1.75-vendor-rk35xx #1 SMP Mon Sep  2 13:12:21 UTC 2024 aarch64 aarch64 aarch64 GNU/Linux

 

Link to comment
Share on other sites

  • Solution
cp /lib/firmware/arm/mali/arch10.8/mali_csffw.bin /lib/firmware

 docker exec -it jellyfin /usr/lib/jellyfin-ffmpeg/ffmpeg -v debug -init_hw_device rkmpp=rk -init_hw_device opencl=ocl@rk
ffmpeg version 6.0.1-Jellyfin Copyright (c) 2000-2023 the FFmpeg developers
  built with gcc 12 (Debian 12.2.0-14)
  configuration: --prefix=/usr/lib/jellyfin-ffmpeg --target-os=linux --extra-version=Jellyfin --disable-doc --disable-ffplay --disable-ptx-compression --disable-static --disable-libxcb --disable-sdl2 --disable-xlib --enable-lto --enable-gpl --enable-version3 --enable-shared --enable-gmp --enable-gnutls --enable-chromaprint --enable-opencl --enable-libdrm --enable-libxml2 --enable-libass --enable-libfreetype --enable-libfribidi --enable-libfontconfig --enable-libbluray --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvorbis --enable-libopenmpt --enable-libdav1d --enable-libsvtav1 --enable-libwebp --enable-libvpx --enable-libx264 --enable-libx265 --enable-libzvbi --enable-libzimg --enable-libfdk-aac --arch=arm64 --cross-prefix=/usr/bin/aarch64-linux-gnu- --toolchain=hardened --enable-cross-compile --enable-rkmpp --enable-rkrga
  libavutil      58.  2.100 / 58.  2.100
  libavcodec     60.  3.100 / 60.  3.100
  libavformat    60.  3.100 / 60.  3.100
  libavdevice    60.  1.100 / 60.  1.100
  libavfilter     9.  3.100 /  9.  3.100
  libswscale      7.  1.100 /  7.  1.100
  libswresample   4. 10.100 /  4. 10.100
  libpostproc    57.  1.100 / 57.  1.100
Splitting the commandline.
Reading option '-v' ... matched as option 'v' (set logging level) with argument 'debug'.
Reading option '-init_hw_device' ... matched as option 'init_hw_device' (initialise hardware device) with argument 'rkmpp=rk'.
Reading option '-init_hw_device' ... matched as option 'init_hw_device' (initialise hardware device) with argument 'opencl=ocl@rk'.
Finished splitting the commandline.
Parsing a group of options: global .
Applying option v (set logging level) with argument debug.
Applying option init_hw_device (initialise hardware device) with argument rkmpp=rk.
Applying option init_hw_device (initialise hardware device) with argument opencl=ocl@rk.
arm_release_ver: g13p0-01eac0, rk_so_ver: 10
[AVHWDeviceContext @ 0xaaaac71b4f00] 1 OpenCL platforms found.
[AVHWDeviceContext @ 0xaaaac71b4f00] 1 OpenCL devices found on platform "ARM Platform".
[AVHWDeviceContext @ 0xaaaac71b4f00] 0.0: ARM Platform / Mali-G610 r0p0
[AVHWDeviceContext @ 0xaaaac71b4f00] cl_arm_import_memory found as platform extension.
[AVHWDeviceContext @ 0xaaaac71b4f00] cl_khr_image2d_from_buffer found as platform extension.
[AVHWDeviceContext @ 0xaaaac71b4f00] DRM to OpenCL mapping on ARM function found (clImportMemoryARM).
Successfully parsed a group of options.
Hyper fast Audio and Video encoder
usage: ffmpeg [options] [[infile options] -i infile]... {[outfile options] outfile}...

Use -h to get full help or, even better, run 'man ffmpeg'


 dmesg|grep Mali
[  367.986293] mali fb000000.gpu: Loading Mali firmware 0x1010000
[  367.988606] mali fb000000.gpu: Mali firmware git_sha: 814b47b551159067b67a37c4e9adda458ad9d852

Seems the firmware not on the right folder see above :

Edited by Rdlop
Link to comment
Share on other sites

4 hours ago, Rdlop said:
[AVHWDeviceContext @ 0xaaaac71b4f00] 1 OpenCL platforms found.
[AVHWDeviceContext @ 0xaaaac71b4f00] 1 OpenCL devices found on platform "ARM Platform".
[AVHWDeviceContext @ 0xaaaac71b4f00] 0.0: ARM Platform / Mali-G610 r0p0
[AVHWDeviceContext @ 0xaaaac71b4f00] cl_arm_import_memory found as platform extension.
[AVHWDeviceContext @ 0xaaaac71b4f00] cl_khr_image2d_from_buffer found as platform extension.
[AVHWDeviceContext @ 0xaaaac71b4f00] DRM to OpenCL mapping on ARM function found (clImportMemoryARM).

 

I see that the driver is loaded correctly, for check status of VPU run:

 

cat /sys/kernel/debug/rkrga/load

 

Link to comment
Share on other sites

acas@t6:~$ sudo dmesg | grep -i panthor
[    7.838279] panthor fb000000.gpu-panthor: [drm] clock rate = 198000000
[    7.838367] panthor fb000000.gpu-panthor: Looking up mali-supply from device tree
[    7.839653] panthor fb000000.gpu-panthor: Looking up sram-supply from device tree
[    7.839662] panthor fb000000.gpu-panthor: Looking up sram-supply property in node /gpu-panthor@fb000000 failed
[    7.844455] panthor fb000000.gpu-panthor: EM: OPP:400000 is inefficient
[    7.844460] panthor fb000000.gpu-panthor: EM: OPP:300000 is inefficient
[    7.844541] panthor fb000000.gpu-panthor: EM: created perf domain
[    7.844722] panthor fb000000.gpu-panthor: [drm] mali-g610 id 0xa867 major 0x0 minor 0x0 status 0x5
[    7.844726] panthor fb000000.gpu-panthor: [drm] Features: L2:0x7120306 Tiler:0x809 Mem:0x301 MMU:0x2830 AS:0xff
[    7.844729] panthor fb000000.gpu-panthor: [drm] shader_present=0x50005 l2_present=0x1 tiler_present=0x1
[    7.857514] panthor fb000000.gpu-panthor: [drm] Firmware protected mode entry not be supported, ignoring
[    7.857895] panthor fb000000.gpu-panthor: [drm] CSF FW v1.1.0, Features 0x0 Instrumentation features 0x71
[    7.858927] [drm] Initialized panthor 1.0.0 20230801 for fb000000.gpu-panthor on minor 2

for me, mali firmware is located in:
 

acas@t6:~$ find /lib/firmware -name mali*.bin
/lib/firmware/arm/mali/arch10.8/mali_csffw.bin
/lib/firmware/mali_csffw.bin

the latter being a legacy location, just there for posterity 😀

Link to comment
Share on other sites

other comparative info -
 

acas@t6:~$ find /lib/firmware -name mali*.bin -ls
 76559798    268 -rw-rw-r--   1 root     root       274432 Jun 26 22:44 /lib/firmware/arm/mali/arch10.8/mali_csffw.bin
 76582704    268 -rw-r--r--   1 root     root       274432 Aug 10 16:46 /lib/firmware/mali_csffw.bin
acas@t6:~$ sha256sum /lib/firmware/mali_csffw.bin 
8e7c821a55ca1c345cc79f61243616dd25fc35b81f090946f302886d67712df5  /lib/firmware/mali_csffw.bin

acas@t6:~$ dpkg -l | grep -i mesa
ii  libegl-mesa0:arm64                            24.2.2~kisak1~n                               arm64        free implementation of the EGL API -- Mesa vendor library
ii  libgl1-mesa-dri:arm64                         24.2.2~kisak1~n                               arm64        free implementation of the OpenGL API -- DRI modules
ii  libglapi-mesa:arm64                           24.2.2~kisak1~n                               arm64        free implementation of the GL API -- shared library
ii  libglx-mesa0:arm64                            24.2.2~kisak1~n                               arm64        free implementation of the OpenGL API -- GLX vendor library
ii  mesa-libgallium:arm64                         24.2.2~kisak1~n                               arm64        shared infrastructure for Mesa drivers
ii  mesa-utils                                    9.0.0-2                                       arm64        Miscellaneous Mesa utilities -- symlinks
ii  mesa-utils-bin:arm64                          9.0.0-2                                       arm64        Miscellaneous Mesa utilities -- native applications

 

Link to comment
Share on other sites

cat /sys/kernel/debug/rkrga/load
num of scheduler = 3
================= load ==================
scheduler[0]: rga3
         load = 38%
-----------------------------------
scheduler[1]: rga3
         load = 15%
-----------------------------------
scheduler[2]: rga2
         load = 0%
-----------------------------------
         process 3: pid = 402989, name: /usr/lib/jellyfin-ffmpeg/ffmpeg -analyzeduration 200M -probesize 1G -ss 00:10:15.000 -noaccurate_seek -init_hw_device rkmpp=rk -hwaccel rkmpp -hwaccel_output_format drm_prime -afbc rga -noautorotate -i file:/test/file.mkv -noautoscale -map_metadata -1 -map_chapters -1 -threads 0 -map 0:0 -map 0:1 -map -0:s -codec:v:0 h264_rkmpp -b:v 8000870 -maxrate 8000870 -bufsize 16001740 -profile:v:0 high -level 51 -g:v:0 72 -keyint_min:v:0 72 -vf setparams=color_primaries=bt709:color_trc=bt709:colorspace=bt709,scale_rkrga=format=nv12:afbc=1 -codec:a:0 copy -copyts -avoid_negative_ts disabled -max_muxing_queue_size 2048 -f hls -max_delay 5000000 -hls_time 3 -hls_segment_type fmp4 -hls_fmp4_init_filename 9bb28fb24386e8308d1d11e086c248d8-1.mp4 -start_number 205 -hls_segment_filename /cache/transcodes/9bb28fb24386e8308d1d11e086c248d8%d.mp4 -hls_playlist_type vod -hls_list_size 0 -y /cache/transcodes/9bb28fb24386e8308d1d11e086c248d8.m3u8

It seems ok

Link to comment
Share on other sites

Depending on what you want (headless?), you may not need it - https://www.collabora.com/news-and-blog/news-and-events/release-the-panthor.html

 

But if you do want it - ensure panthor-gpu is present in loaded overlays (no other is needed)
 

acas@t6:~$ grep overlays /boot/armbianEnv.txt 
overlays=panthor-gpu rk3588-hdmirx
acas@t6:~$ find /lib/modules/ -name \*panthor\* -ls
 76560560      4 drwxr-xr-x   2 root     root         4096 Sep  7 19:19 /lib/modules/6.1.75-vendor-rk35xx/kernel/drivers/gpu/drm/panthor
 76560716    180 -rw-r--r--   1 root     root       182920 Sep  7 19:10 /lib/modules/6.1.75-vendor-rk35xx/kernel/drivers/gpu/drm/panthor/panthor.ko

then you should see its messages after system boot.

Link to comment
Share on other sites

find /lib/modules/ -name \*panthor\* -ls
  6950038      4 drwxr-xr-x   2 root     root         4096 août 26 18:21 /lib/modules/6.1.75-vendor-rk35xx/kernel/drivers/gpu/drm/panthor
  6951151    180 -rw-r--r--   1 root     root       182920 août 24 19:27 /lib/modules/6.1.75-vendor-rk35xx/kernel/drivers/gpu/drm/panthor/panthor.ko

I've got them right.

And yes i'm doing headless

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...

Important Information

Terms of Use - Privacy Policy - Guidelines