Jellyfin Forum
SOLVED: Ubntu Server - Docker HW transcoding: Cannot load libcuda.so.1 - 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: Ubntu Server - Docker HW transcoding: Cannot load libcuda.so.1 (/t-solved-ubntu-server-docker-hw-transcoding-cannot-load-libcuda-so-1)



Ubntu Server - Docker HW transcoding: Cannot load libcuda.so.1 - agendi - 2024-03-16

I've read heaps of various forums, each ultimately being checked as solved but none of the fixes seem to work for me.

Ubuntu Server 22.04.4 LTS
AMD Ryzen 4, 12 threads
16gb RAM
NVIDIA Geforce GTX 980ti

Jellyfin:latest installed via Docker.

Code:
media:~/docker/jellyfin$ nvidia-smi
Sat Mar 16 21:00:58 2024     
+-----------------------------------------------------------------------------------------+
| NVIDIA-SMI 550.54.14              Driver Version: 550.54.14      CUDA Version: 12.4    |
|-----------------------------------------+------------------------+----------------------+
| 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 GTX 980 Ti      Off |  00000000:08:00.0 Off |                  N/A |
| 33%  41C    P8            32W /  260W |      1MiB /  6144MiB |      0%      Default |
|                                        |                        |                  N/A |
+-----------------------------------------+------------------------+----------------------+
                                                                                       
+-----------------------------------------------------------------------------------------+
| Processes:                                                                              |
|  GPU  GI  CI        PID  Type  Process name                              GPU Memory |
|        ID  ID                                                              Usage      |
|=========================================================================================|
|  No running processes found                                                            |
+-----------------------------------------------------------------------------------------+

media:~/docker/jellyfin$ sudo apt install libnvidia-decode-550
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
libnvidia-decode-550 is already the newest version (550.54.14-0ubuntu1).
libnvidia-decode-550 set to manually installed.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

media:~/docker/jellyfin$ sudo apt install libnvidia-encode-550
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
libnvidia-encode-550 is already the newest version (550.54.14-0ubuntu1).
libnvidia-encode-550 set to manually installed.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

media:~/docker/jellyfin$ lspci -nn | egrep -i "3d|display|vga"
08:00.0 VGA compatible controller [0300]: NVIDIA Corporation GM200 [GeForce GTX 980 Ti] [10de:17c8] (rev a1)

CUDA installed on Host. Nvidia Docker toolkit installed and working

Code:
media:~/docker/jellyfin$ sudo docker run --rm --runtime=nvidia --gpus all ubuntu nvidia-smi
Sat Mar 16 10:16:08 2024     
+-----------------------------------------------------------------------------------------+
| NVIDIA-SMI 550.54.14              Driver Version: 550.54.14      CUDA Version: 12.4    |
|-----------------------------------------+------------------------+----------------------+
| 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 GTX 980 Ti      Off |  00000000:08:00.0 Off |                  N/A |
| 33%  41C    P8            32W /  260W |      1MiB /  6144MiB |      0%      Default |
|                                        |                        |                  N/A |
+-----------------------------------------+------------------------+----------------------+
                                                                                       
+-----------------------------------------------------------------------------------------+
| Processes:                                                                              |
|  GPU  GI  CI        PID  Type  Process name                              GPU Memory |
|        ID  ID                                                              Usage      |
|=========================================================================================|
|  No running processes found                                                            |
+-----------------------------------------------------------------------------------------+

Docker-compose:

Code:
version: '3.5'
services:
  jellyfin:
    image: jellyfin/jellyfin
    container_name: jellyfin
      #network_mode: 'host'
    ports:
      - 8096:8096
    environment:
      - UID=1000
      - GID=1000
      - TZ=Australia/Sydney
      - JELLYFIN_PublishedServerUrl=http://media.local
      - NVIDIA_DRIVER_CAPABILITIES=all
      - NVIDIA_VISIBLE_DEVICES=all
    group_add:
      - 109
      - 44
    volumes:
      - ./config:/config
      - /storage/cache:/cache
      - /storage/media:/media
      - /dev/shm:/transcode
    devices:
      - /dev/dri/renderD128:/dev/dri/renderD128
      - /dev/dri/card0:/dev/dri/card0
    restart: always
    runtime: nvidia
    deploy:
      resources:
        reservations:
          devices:
            - driver: nvidia
              count: 1
              capabilities: ["gpu", "utility"]

JF transcode Error Log:
Code:
[color=#000000]/videos/f7e94857-9638-4808-47bf-d6ae3abee141/hls1/main/0.ts
{"Protocol":0,"Id":"f7e948579638480847bfd6ae3abee141","Path":"/media/movie/The Wheel of Time - The Eye of the World (2021)/The Wheel of Time - The Eye of the World (2021).mkv","EncoderPath":null,"EncoderProtocol":null,"Type":0,"Container":"mkv,webm","Size":14386871296,"Name":"The Wheel of Time - The Eye of the World (2021)","IsRemote":false,"ETag":"e1aa3db25cc9f3f2fc26f212f11ea16b","RunTimeTicks":159983992832,"ReadAtNativeFramerate":false,"IgnoreDts":false,"IgnoreIndex":false,"GenPtsInput":false,"SupportsTranscoding":true,"SupportsDirectStream":true,"SupportsDirectPlay":true,"IsInfiniteStream":false,"RequiresOpening":false,"OpenToken":null,"RequiresClosing":false,"LiveStreamId":null,"BufferMs":null,"RequiresLooping":false,"SupportsProbing":true,"VideoType":0,"IsoType":null,"Video3DFormat":null,"MediaStreams":[{"Codec":"hevc","CodecTag":null,"Language":"eng","ColorRange":null,"ColorSpace":null,"ColorTransfer":null,"ColorPrimaries":null,"DvVersionMajor":null,"DvVersionMinor":null,"DvProfile":null,"DvLevel":null,"RpuPresentFlag":null,"ElPresentFlag":null,"BlPresentFlag":null,"DvBlSignalCompatibilityId":null,"Comment":null,"TimeBase":"1/1000","CodecTimeBase":null,"Title":null,"VideoRange":"SDR","VideoRangeType":"SDR","VideoDoViTitle":null,"LocalizedUndefined":null,"LocalizedDefault":null,"LocalizedForced":null,"LocalizedExternal":null,"DisplayTitle":"1080p HEVC SDR","NalLengthSize":null,"IsInterlaced":false,"IsAVC":null,"ChannelLayout":null,"BitRate":7194155,"BitDepth":8,"RefFrames":1,"PacketLength":null,"Channels":null,"SampleRate":null,"IsDefault":true,"IsForced":false,"Height":880,"Width":1920,"AverageFrameRate":23.976025,"RealFrameRate":23.976025,"Profile":"Main","Type":1,"AspectRatio":"24:11","Index":0,"Score":null,"IsExternal":false,"DeliveryMethod":null,"DeliveryUrl":null,"IsExternalUrl":null,"IsTextSubtitleStream":false,"SupportsExternalStream":false,"Path":null,"PixelFormat":"yuv420p","Level":150,"IsAnamorphic":null},{"Codec":"aac","CodecTag":null,"Language":"eng","ColorRange":null,"ColorSpace":null,"ColorTransfer":null,"ColorPrimaries":null,"DvVersionMajor":null,"DvVersionMinor":null,"DvProfile":null,"DvLevel":null,"RpuPresentFlag":null,"ElPresentFlag":null,"BlPresentFlag":null,"DvBlSignalCompatibilityId":null,"Comment":null,"TimeBase":"1/1000","CodecTimeBase":null,"Title":null,"VideoRange":null,"VideoRangeType":null,"VideoDoViTitle":null,"LocalizedUndefined":null,"LocalizedDefault":null,"LocalizedForced":null,"LocalizedExternal":null,"DisplayTitle":"Eng - AAC - 5.1 - Default","NalLengthSize":null,"IsInterlaced":false,"IsAVC":null,"ChannelLayout":"5.1","BitRate":538032,"BitDepth":null,"RefFrames":null,"PacketLength":null,"Channels":6,"SampleRate":48000,"IsDefault":true,"IsForced":false,"Height":null,"Width":null,"AverageFrameRate":null,"RealFrameRate":null,"Profile":"LC","Type":0,"AspectRatio":null,"Index":1,"Score":null,"IsExternal":false,"DeliveryMethod":null,"DeliveryUrl":null,"IsExternalUrl":null,"IsTextSubtitleStream":false,"SupportsExternalStream":false,"Path":null,"PixelFormat":null,"Level":0,"IsAnamorphic":null}],"MediaAttachments":[],"Formats":[],"Bitrate":7732187,"Timestamp":null,"RequiredHttpHeaders":{},"TranscodingUrl":null,"TranscodingSubProtocol":null,"TranscodingContainer":null,"AnalyzeDurationMs":null,"DefaultAudioStreamIndex":null,"DefaultSubtitleStreamIndex":null}
/usr/lib/jellyfin-ffmpeg/ffmpeg -analyzeduration 200M -init_hw_device cuda=cu:0 -filter_hw_device cu -hwaccel cuda -hwaccel_output_format cuda -threads 1 -autorotate 0 -i file:"/media/movie/The Wheel of Time - The Eye of the World (2021)/The Wheel of Time - The Eye of the World (2021).mkv" -autoscale 0 -map_metadata -1 -map_chapters -1 -threads 0 -map 0:0 -map 0:1 -map -0:s -codec:v:0 h264_nvenc -preset p1 -b:v 11990258 -maxrate 11990258 -bufsize 23980516 -g:v:0 72 -keyint_min:v:0 72 -vf "setparams=color_primaries=bt709:color_trc=bt709:colorspace=bt709,scale_cuda=format=yuv420p" -codec:a:0 libfdk_aac -ac 2 -ab 384000 -ar 48000 -af "volume=2" -copyts -avoid_negative_ts disabled -max_muxing_queue_size 2048 -f hls -max_delay 5000000 -hls_time 3 -hls_segment_type mpegts -start_number 0 -hls_segment_filename "/config/transcodes/8549c999df642daf16c230480eff3dd6%d.ts" -hls_playlist_type vod -hls_list_size 0 -y "/config/transcodes/8549c999df642daf16c230480eff3dd6.m3u8"
ffmpeg version 5.1.4-Jellyfin Copyright (c) 2000-2023 the FFmpeg developers
  built with gcc 10 (Debian 10.2.1-6)
  configuration: --prefix=/usr/lib/jellyfin-ffmpeg --target-os=linux --extra-libs=-lfftw3f --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-libdrm --enable-libass --enable-libfreetype --enable-libfribidi --enable-libfontconfig --enable-libbluray --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvorbis --enable-libopenmpt --enable-libdav1d --enable-libwebp --enable-libvpx --enable-libx264 --enable-libx265 --enable-libzvbi --enable-libzimg --enable-libfdk-aac --arch=amd64 --enable-libsvtav1 --enable-libshaderc --enable-libplacebo --enable-vulkan --enable-opencl --enable-vaapi --enable-amf --enable-libmfx --enable-ffnvcodec --enable-cuda --enable-cuda-llvm --enable-cuvid --enable-nvdec --enable-nvenc
  libavutil      57. 28.100 / 57. 28.100
  libavcodec    59. 37.100 / 59. 37.100
  libavformat    59. 27.100 / 59. 27.100
  libavdevice    59.  7.100 / 59.  7.100
  libavfilter    8. 44.100 /  8. 44.100
  libswscale      6.  7.100 /  6.  7.100
  libswresample  4.  7.100 /  4.  7.100
  libpostproc    56.  6.100 / 56.  6.100
[AVHWDeviceContext @ 0x55b3466ffac0] Cannot load libcuda.so.1
[AVHWDeviceContext @ 0x55b3466ffac0] Could not dynamically load CUDA
Device creation failed: -1.
Failed to set value 'cuda=cu:0' for option 'init_hw_device': Operation not permitted
Error parsing global [/color][color=#ffffff]options: Operation not permitted[/color]

FFMPEG command when trying to transcode to Android phone running Jellyfin app:
Code:
[color=#000000]/usr/lib/jellyfin-ffmpeg/ffmpeg" "-analyzeduration 200M -init_hw_device cuda=cu:0 -filter_hw_device cu -hwaccel cuda -hwaccel_output_format cuda -threads 1 -autorotate 0 -i file:\"/media/movie/The Wheel of Time - The Eye of the World (2021)/The Wheel of Time - The Eye of the World (2021).mkv\" -autoscale 0 -map_metadata -1 -map_chapters -1 -threads 0 -map 0:0 -map 0:1 -map -0:s -codec:v:0 h264_nvenc -preset p1 -b:v 11990258 -maxrate 11990258 -bufsize 23980516 -g:v:0 72 -keyint_min:v:0 72 -vf \"setparams=color_primaries=bt709:color_trc=bt709:colorspace=bt709,scale_cuda=format=yuv420p\" -codec:a:0 libfdk_aac -ac 2 -ab 384000 -ar 48000 -af \"volume=2\" -copyts -avoid_negative_ts disabled -max_muxing_queue_size 2048 -f hls -max_delay 5000000 -hls_time 3 -hls_segment_type mpegts -start_number 0 -hls_segment_filename \"/config/transcodes/8549c999df642daf16c230480eff3dd6%d.ts\" -hls_playlist_type vod -hls_list_size 0 -y \"/config/transcod[/color][color=#ffffff]es/8549c999df642daf16c230480eff3dd6.m3u8\"[/color]
 

As far as I can tell I've given all the required permissions. Jellyfin is in the video and render groups. There is no problems accessing the underlying files.

Finally the JF playback screen is attached

Thanks for any assistance and also for a strong, helpful community.


RE: Ubntu Server - Docker HW transcoding: Cannot load libcuda.so.1 - TheDreadPirate - 2024-03-16

If you are running the container as your user you need to add your user to the video group. Step 4 on this guide.

https://jellyfin.org/docs/general/administration/hardware-acceleration/nvidia/#configure-with-linux-virtualization


RE: Ubntu Server - Docker HW transcoding: Cannot load libcuda.so.1 - agendi - 2024-03-17

I've already ensured they user has permissions. It has video and render.
The container is running as UID:1000 and GID:1000

george@media:~$ groups
george adm cdrom sudo dip video plugdev render lxd
george@media:~$ id
uid=1000(george) gid=1000(george) groups=1000(george),4(adm),24(cdrom),27(sudo),30(dip),44(video),46(plugdev),109(render),110(lxd)
george@media:~$


RE: Ubntu Server - Docker HW transcoding: Cannot load libcuda.so.1 - TheDreadPirate - 2024-03-17

Code:
sudo apt list --installed | egrep "nvidia|libnv"



RE: Ubntu Server - Docker HW transcoding: Cannot load libcuda.so.1 - agendi - 2024-03-17

Code:
libnvfatbin-12-4/unknown,now 12.4.99-1 amd64 [installed,automatic]
libnvfatbin-dev-12-4/unknown,now 12.4.99-1 amd64 [installed,automatic]
libnvidia-cfg1-550/unknown,now 550.54.14-0ubuntu1 amd64 [installed,automatic]
libnvidia-common-550/unknown,now 550.54.14-0ubuntu1 all [installed,automatic]
libnvidia-compute-550/unknown,now 550.54.14-0ubuntu1 amd64 [installed,automatic]
libnvidia-container-tools/unknown,now 1.14.6-1 amd64 [installed,automatic]
libnvidia-container1/unknown,now 1.14.6-1 amd64 [installed,automatic]
libnvidia-decode-550/unknown,now 550.54.14-0ubuntu1 amd64 [installed]
libnvidia-encode-550/unknown,now 550.54.14-0ubuntu1 amd64 [installed]
libnvidia-extra-550/unknown,now 550.54.14-0ubuntu1 amd64 [installed,automatic]
libnvidia-fbc1-550/unknown,now 550.54.14-0ubuntu1 amd64 [installed,automatic]
libnvidia-gl-550/unknown,now 550.54.14-0ubuntu1 amd64 [installed,automatic]
libnvjitlink-12-4/unknown,now 12.4.99-1 amd64 [installed,automatic]
libnvjitlink-dev-12-4/unknown,now 12.4.99-1 amd64 [installed,automatic]
libnvjpeg-12-4/unknown,now 12.3.1.89-1 amd64 [installed,automatic]
libnvjpeg-dev-12-4/unknown,now 12.3.1.89-1 amd64 [installed,automatic]
nvidia-compute-utils-550/unknown,now 550.54.14-0ubuntu1 amd64 [installed,automatic]
nvidia-container-toolkit-base/unknown,now 1.14.6-1 amd64 [installed,automatic]
nvidia-container-toolkit/unknown,now 1.14.6-1 amd64 [installed]
nvidia-dkms-550/unknown,now 550.54.14-0ubuntu1 amd64 [installed,automatic]
nvidia-driver-550/unknown,now 550.54.14-0ubuntu1 amd64 [installed,automatic]
nvidia-firmware-550-550.54.14/unknown,now 550.54.14-0ubuntu1 amd64 [installed,automatic]
nvidia-kernel-common-550/unknown,now 550.54.14-0ubuntu1 amd64 [installed,automatic]
nvidia-kernel-source-550/unknown,now 550.54.14-0ubuntu1 amd64 [installed,automatic]
nvidia-prime/jammy,now 0.8.17.1 all [installed,automatic]
nvidia-settings/unknown,now 550.54.14-0ubuntu1 amd64 [installed,automatic]
nvidia-utils-550/unknown,now 550.54.14-0ubuntu1 amd64 [installed,automatic]
xserver-xorg-video-nvidia-550/unknown,now 550.54.14-0ubuntu1 amd64 [installed,automatic]



RE: Ubntu Server - Docker HW transcoding: Cannot load libcuda.so.1 - TheDreadPirate - 2024-03-17

Did you recently update the container toolkit or something? I wonder if you have to redo the configuration setup steps.

https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/install-guide.html#configuration


RE: Ubntu Server - Docker HW transcoding: Cannot load libcuda.so.1 - agendi - 2024-03-18

I updated it a few days ago and have rebooted the server (not only the containers). The messages haven't changed.

I am wondering if it is the video I am trying to transcode - its a 1080P H265 .mkv, I was reading that a GTX 980ti should be able to do single stream trancoding of H265 that isn't 4k. The GPU chipset should be 2nd gen Maxwell.

Thanks for helping me out. I am totally stumped.


RE: Ubntu Server - Docker HW transcoding: Cannot load libcuda.so.1 - TheDreadPirate - 2024-03-18

Look at this Nvidia codec matrix and make sure you don't have any codec boxes chceked that your GPU can't decode. From your first post, definitely uncheck HEVC and uncheck "allow encoding in HEVC".

https://developer.nvidia.com/video-encode-and-decode-gpu-support-matrix-new


RE: Ubntu Server - Docker HW transcoding: Cannot load libcuda.so.1 - agendi - 2024-03-18

That did it. Thank you for the help.