Jellyfin Forum
SOLVED: Can't access GPU in docker container - Printable Version

+- Jellyfin Forum (https://forum.jellyfin.org)
+-- Forum: Support (https://forum.jellyfin.org/f-support)
+--- Forum: Troubleshooting (https://forum.jellyfin.org/f-troubleshooting)
+--- Thread: SOLVED: Can't access GPU in docker container (/t-solved-can-t-access-gpu-in-docker-container)



Can't access GPU in docker container - creylon - 2024-04-29

Hi,

I am trying to run the unstable branch with hardware acceleration. I have an AMD GPU.

Here is my docker config:

Code:
  jellyfin-beta:
    container_name: jellyfin-beta
    image: ghcr.io/jellyfin/jellyfin:unstable
    group_add:
      - "989" # render group
      - "986" # video group
      - "993" # input group
    dns:
      - 1.1.1.1
    volumes:
      - "./config.beta:/config"
      - "./cache.beta:/cache"
      - "./config.json:/jellyfin/jellyfin-web/config.json"
      - "/home/media:/media:ro"
    devices:
      # VAAPI Devices
      - /dev/dri/renderD129:/dev/dri/renderD128
      - /dev/dri/card1:/dev/dri/card0
    restart: always

When I run

Code:
docker exec -it jellyfin-beta /usr/lib/jellyfin-ffmpeg/vainfo --display drm --device /dev/dri/renderD128

I get the following error:

Code:
Trying display: drm

Failed to a DRM display for the given device

This error occurs as of unstable build 2024032505. With previous builds everything works fine. I run another jellyfin instance with stable branch and same configuration without issues.

Thanks


RE: Can't access GPU in docker container - TheDreadPirate - 2024-04-29

Try swapping out /dev/dri/card0 with "/dev/kfd".


RE: Can't access GPU in docker container - creylon - 2024-04-29

So I tried

Code:
    devices:
      - /dev/dri/renderD129:/dev/dri/renderD128
      - /dev/dri/card1:/dev/kfd

and

Code:
    devices:
      - /dev/dri/renderD129:/dev/dri/renderD128
      - /dev/kfd:/dev/kfd

neither worked, same error. I don't use OpenCL btw


RE: Can't access GPU in docker container - TheDreadPirate - 2024-04-29

Just realized you're using a month old build. Can you re-pull the image and grab today's build? 2024042905


RE: Can't access GPU in docker container - creylon - 2024-04-29

I am using unstable tag for the image, which has the latest build from today. The error occurs first with build 2024032505. So in build 2024031805 this config works fine.


RE: Can't access GPU in docker container - TheDreadPirate - 2024-04-29

What GPU is in your system? I spun up unstable on my desktop with an RX6800 and it appears to transcode as expected with vulkan.

Code:
/usr/lib/jellyfin-ffmpeg/ffmpeg -analyzeduration 200M -probesize 1G -init_hw_device drm=dr:/dev/dri/renderD128 -init_hw_device vaapi=va@dr -init_hw_device vulkan=vk@dr -filter_hw_device vk -hwaccel vaapi -hwaccel_output_format vaapi -noautorotate -i file:"/media/library/Anime Movies/5 Centimeters per Second (2007)/5 Centimeters per Second.mkv" -noautoscale -map_metadata -1 -map_chapters -1 -threads 0 -map 0:0 -map 0:1 -map -0:s -codec:v:0 h264_vaapi -rc_mode VBR -b:v 17895107 -maxrate 17895107 -bufsize 35790214 -sei -a53_cc -force_key_frames:0 "expr:gte(t,n_forced*3)" -vf "setparams=color_primaries=bt709:color_trc=bt709:colorspace=bt709,scale_vaapi=format=nv12" -codec:a:0 libfdk_aac -ac 2 -ab 256000 -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 "64f6bedc7a7eec0752e5ac99bd812839-1.mp4" -start_number 0 -hls_segment_filename "/config/transcodes/64f6bedc7a7eec0752e5ac99bd812839%d.mp4" -hls_playlist_type vod -hls_list_size 0 -y "/config/transcodes/64f6bedc7a7eec0752e5ac99bd812839.m3u8"

Code:
root@optimus-maximus:/docker/jellyfin/jellyfin-data/config/log# docker exec -it jellyfin /usr/lib/jellyfin-ffmpeg/vainfo --display drm --device /dev/dri/renderD128
Trying display: drm
libva info: VA-API version 1.21.0
libva info: Trying to open /usr/lib/jellyfin-ffmpeg/lib/dri/radeonsi_drv_video.so
libva info: Found init function __vaDriverInit_1_21
amdgpu: os_same_file_description couldn't determine if two DRM fds reference the same file description.
If they do, bad things may happen!
libva info: va_openDriver() returns 0
vainfo: VA-API version: 1.21 (libva 2.21.0)
vainfo: Driver version: Mesa Gallium driver 24.0.5 for AMD Radeon RX 6800 (radeonsi, navi21, LLVM 16.0.6, DRM 3.54, 6.5.0-28-generic)
vainfo: Supported profile and entrypoints
      VAProfileMPEG2Simple            :    VAEntrypointVLD
      VAProfileMPEG2Main              :    VAEntrypointVLD
      VAProfileVC1Simple              :    VAEntrypointVLD
      VAProfileVC1Main                :    VAEntrypointVLD
      VAProfileVC1Advanced            :    VAEntrypointVLD
      VAProfileH264ConstrainedBaseline:    VAEntrypointVLD
      VAProfileH264ConstrainedBaseline:    VAEntrypointEncSlice
      VAProfileH264Main               :    VAEntrypointVLD
      VAProfileH264Main               :    VAEntrypointEncSlice
      VAProfileH264High               :    VAEntrypointVLD
      VAProfileH264High               :    VAEntrypointEncSlice
      VAProfileHEVCMain               :    VAEntrypointVLD
      VAProfileHEVCMain               :    VAEntrypointEncSlice
      VAProfileHEVCMain10             :    VAEntrypointVLD
      VAProfileHEVCMain10             :    VAEntrypointEncSlice
      VAProfileJPEGBaseline           :    VAEntrypointVLD
      VAProfileVP9Profile0            :    VAEntrypointVLD
      VAProfileVP9Profile2            :    VAEntrypointVLD
      VAProfileAV1Profile0            :    VAEntrypointVLD
      VAProfileNone                   :    VAEntrypointVideoProc

My docker compose for reference.

Code:
services:
  jellyfin:
    image: jellyfin/jellyfin:unstable
    container_name: jellyfin
    user: 1000:1000
    group_add:
      - "44" #video
      - "105" #render
    network_mode: 'host'
    volumes:
      - ./jellyfin-data/config:/config
      - ./jellyfin-data/cache:/cache
      - /media:/media:ro
    restart: 'unless-stopped'
    environment:
      - ROC_ENABLE_PRE_VEGA=1
    devices:
      - /dev/dri:/dev/dri
      - /dev/kfd:/dev/kfd
    extra_hosts:
      - "host.docker.internal:host-gateway"

I am not specifying the device, just providing the whole /dev/dri folder. I noticed you were using renderD129, do you have more than one device? Perhaps an Intel iGPU?


RE: Can't access GPU in docker container - creylon - 2024-04-29

I've got a Ryzen 5 5600G which has builtin GPU and a dedicated Radeon RX 5500. As I want to use the dedicated GPU I map renderD129.

I mapped the devices like you did:

Code:
    devices:
      - /dev/dri:/dev/dri
      - /dev/kfd:/dev/kfd

Now it works. I don't understand why that would make a difference, but thanks for the help


RE: Can't access GPU in docker container - TheDreadPirate - 2024-04-29

Yep. Since you can specify the render device with VAAPI you can still tell it to use renderD129 that way. Why that makes a difference, IDK.