Jellyfin / Intel N100 GPU decoding on nixos VM

I got an up to date NixOS 24.11, following nixpkgs stable, VM on which i have a jellyfin server installed. my (partial) config is the following :

boot.kernelParams = [ "i915.force_probe=a721" ];
    environment = {
      sessionVariables = { LIBVA_DRIVER_NAME = "iHD"; };
      systemPackages = with pkgs; [
        cifs-utils
        intel-gpu-tools
      ];
    };
    # Intel Hardware Acceleration config
    hardware = {
      graphics = {
        enable = true;
        extraPackages = with pkgs; [
          intel-media-driver
          vaapiVdpau
          libvdpau-va-gl
          intel-compute-runtime # OpenCL filter support (hardware tonemapping and subtitle burn-in)
          vpl-gpu-rt # QSV on 11th gen or newer
        ];
        extraPackages32 = with pkgs.pkgsi686Linux; [
          intel-vaapi-driver
        ];
      };
    };
    services = {
      jellyfin= {
        enable = true;
        user = "tbarnouin";
        openFirewall = true;
      };
    };

I can’t get hardware decoding to work properly, here is my nix-shell -p libva-utils --run vainfo output :

Trying display: wayland
Trying display: x11
error: can't connect to X server!
Trying display: drm
libva info: VA-API version 1.22.0
libva info: User environment variable requested driver 'iHD'
libva info: Trying to open /run/opengl-driver/lib/dri/iHD_drv_video.so
libva info: Found init function __vaDriverInit_1_22
libva info: va_openDriver() returns 0
vainfo: VA-API version: 1.22 (libva 2.22.0)
vainfo: Driver version: Intel iHD driver for Intel(R) Gen Graphics - 24.3.4 ()
vainfo: Supported profile and entrypoints
      VAProfileNone                   :	VAEntrypointVideoProc
      VAProfileNone                   :	VAEntrypointStats

From what i saw on internet i’m missing some VA profile. I’m also missing thinks on intel_gpu_top :

intel-gpu-top: Intel Alderlake_n (Gen12) @ /dev/dri/card1 -    0/   0 MHz; 100% RC6;        0 irqs/s

         ENGINES     BUSY                                                                                MI_SEMA MI_WAIT
       Render/3D    0.00% |                                                                            |      0%      0%

HW decoding is working fine on a Debian 12 VM + GPU passthrough with the same settings

AFAIK, environment.sessionVariables does not apply to systemd services, so you’ll have to set systemd.services.jellyfin.environment.LIBVA_DRIVER_NAME = "iHD"; to achieve what you want.

Also, are you sure you’ve enabled hardware transcoding in the Jellyfin admin dashboard? I don’t know whether it’s enabled by default.

Also, it strikes we as very odd that you’re using the 32 bit package for intel-vaapi-driver only. The Jellyfin package for NixOS is definitely for x86_64.

Edit: the iHD driver is in intel-media-driver. intel-vaapi-driver contains the i965 driver, which you probably don’t need.

2 Likes

Thanks for your reply,

This one is a dumb error i made : i tried intel-vaapi-driver instead of media-driver and only replace the 64bit package when reverting those tests. It does not work better with the 32 bit package, nor with the additional env variable in systemd service.

Clinfo return nothing on the VM so there is definitely something wrong with the GPU config rather than jellyfin :

nix-shell -p clinfo --run clinfo     
Number of platforms                               0

ICD loader properties
 ICD loader Name                                 OpenCL ICD Loader
 ICD loader Vendor                               OCL Icd free software
 ICD loader Version                              2.3.2
 ICD loader Profile                              OpenCL 3.0

Edit : i needed to install intel-ocl to have clinfo informations :

Number of platforms                               1
  Platform Name                                   Intel(R) OpenCL
  Platform Vendor                                 Intel(R) Corporation
  Platform Version                                OpenCL 1.2 LINUX
  Platform Profile                                FULL_PROFILE
  Platform Extensions                             cl_khr_icd cl_khr_global_int32_base_atomics cl_khr_global_int32_extended_atomics cl_khr_local_int32_base_atomics cl_khr_local_int32_extended_atomics cl_khr_byte_addressable_store cl_khr_depth_images cl_khr_3d_image_writes cl_intel_exec_by_local_thread cl_khr_spir cl_khr_fp64 
  Platform Extensions function suffix             INTEL

  Platform Name                                   Intel(R) OpenCL
Number of devices                                 1
  Device Name                                     Intel(R) N100
  Device Vendor                                   Intel(R) Corporation
  Device Vendor ID                                0x8086
  Device Version                                  OpenCL 1.2 (Build 475)
  Driver Version                                  1.2.0.475
  Device OpenCL C Version                         OpenCL C 1.2 
  Device Type                                     CPU
  Device Profile                                  FULL_PROFILE
  Device Available                                Yes
  Compiler Available                              Yes
  Linker Available                                Yes
  Max compute units                               4
  Max clock frequency                             0MHz
  Device Partition                                (core)
    Max number of sub-devices                     4
    Supported partition types                     by counts, equally, by names (Intel)
    Supported affinity domains                    (n/a)
  Max work item dimensions                        3
  Max work item sizes                             8192x8192x8192
  Max work group size                             8192
  Preferred work group size multiple (kernel)     128
  Preferred / native vector sizes                 
    char                                                 1 / 32      
    short                                                1 / 16      
    int                                                  1 / 8       
    long                                                 1 / 4       
    half                                                 0 / 0        (n/a)
    float                                                1 / 8       
    double                                               1 / 4        (cl_khr_fp64)
  Half-precision Floating-point support           (n/a)
  Single-precision Floating-point support         (core)
    Denormals                                     Yes
    Infinity and NANs                             Yes
    Round to nearest                              Yes
    Round to zero                                 No
    Round to infinity                             No
    IEEE754-2008 fused multiply-add               No
    Support is emulated in software               No
    Correctly-rounded divide and sqrt operations  No
  Double-precision Floating-point support         (cl_khr_fp64)
    Denormals                                     Yes
    Infinity and NANs                             Yes
    Round to nearest                              Yes
    Round to zero                                 Yes
    Round to infinity                             Yes
    IEEE754-2008 fused multiply-add               Yes
    Support is emulated in software               No
  Address bits                                    64, Little-Endian
  Global memory size                              4111093760 (3.829GiB)
  Error Correction support                        No
  Max memory allocation                           1027773440 (980.2MiB)
  Unified memory for Host and Device              Yes
  Minimum alignment for any data type             128 bytes
  Alignment of base address                       1024 bits (128 bytes)
  Global Memory cache type                        Read/Write
  Global Memory cache size                        524288 (512KiB)
  Global Memory cache line size                   64 bytes
  Image support                                   Yes
    Max number of samplers per kernel             480
    Max size for 1D images from buffer            64235840 pixels
    Max 1D or 2D image array size                 2048 images
    Max 2D image size                             16384x16384 pixels
    Max 3D image size                             2048x2048x2048 pixels
    Max number of read image args                 480
    Max number of write image args                480
  Local memory type                               Global
  Local memory size                               32768 (32KiB)
  Max number of constant args                     480
  Max constant buffer size                        131072 (128KiB)
  Max size of kernel argument                     3840 (3.75KiB)
  Queue properties                                
    Out-of-order execution                        Yes
    Profiling                                     Yes
    Local thread execution (Intel)                Yes
  Prefer user sync for interop                    No
  Profiling timer resolution                      1ns
  Execution capabilities                          
    Run OpenCL kernels                            Yes
    Run native kernels                            Yes
    SPIR versions                                 1.2
  printf() buffer size                            1048576 (1024KiB)
  Built-in kernels                                (n/a)
  Device Extensions                               cl_khr_icd cl_khr_global_int32_base_atomics cl_khr_global_int32_extended_atomics cl_khr_local_int32_base_atomics cl_khr_local_int32_extended_atomics cl_khr_byte_addressable_store cl_khr_depth_images cl_khr_3d_image_writes cl_intel_exec_by_local_thread cl_khr_spir cl_khr_fp64 

NULL platform behavior
  clGetPlatformInfo(NULL, CL_PLATFORM_NAME, ...)  Intel(R) OpenCL
  clGetDeviceIDs(NULL, CL_DEVICE_TYPE_ALL, ...)   Success [INTEL]
  clCreateContext(NULL, ...) [default]            Success [INTEL]
  clCreateContextFromType(NULL, CL_DEVICE_TYPE_DEFAULT)  Success (1)
    Platform Name                                 Intel(R) OpenCL
    Device Name                                   Intel(R) N100
  clCreateContextFromType(NULL, CL_DEVICE_TYPE_CPU)  Success (1)
    Platform Name                                 Intel(R) OpenCL
    Device Name                                   Intel(R) N100
  clCreateContextFromType(NULL, CL_DEVICE_TYPE_GPU)  No devices found in platform
  clCreateContextFromType(NULL, CL_DEVICE_TYPE_ACCELERATOR)  No devices found in platform
  clCreateContextFromType(NULL, CL_DEVICE_TYPE_CUSTOM)  No devices found in platform
  clCreateContextFromType(NULL, CL_DEVICE_TYPE_ALL)  Success (1)
    Platform Name                                 Intel(R) OpenCL
    Device Name                                   Intel(R) N100

ICD loader properties
  ICD loader Name                                 OpenCL ICD Loader
  ICD loader Vendor                               OCL Icd free software
  ICD loader Version                              2.3.2
  ICD loader Profile                              OpenCL 3.0

One other thing, is the user Jellyfin runs under member of the video group? This is required to access the GPU at /dev/dri/card1.

Background:
For graphical sessions started from a display manager or TTY, systemd-logind automatically grants access to devices. But for processes started any other way (e.g. from SSH sessions or as system services), UNIX file permissions are required to get device access.

1 Like

The user running the jellyfin service is member of both video and render

I’ve never heard of OpenCL being used for video decoding, and the Jellyfin documentation only mentions Quick Sync Video and VAAPI for Intel.

The doc says it’s needed for tonemapping and subtitle burnin

1 Like

I’m also wondering about i915.force_probe=a721 kernel parameter. Do you also have it set on your Debian VM? Can you check which module (i915/xe) the Debian VM uses?

I don’t really know which driver is recommended. My Framework Notebook’s i5-1240P seems to be using i915, and video acceleration is working fine.

But I read in the Arch Wiki that there is a difference in firmware loading for the HuC (HEVC/H.265 micro Controller). Which makes me wonder:

  • Does dmesg show any errors related to firmware loading? Have you enabled hardware.enableAllFirmware?
  • Have you set i915.enable_guc? Maybe setting it to 3 can help (see the wiki)

Ok i got it working with your advices, i don’t really know what i’ve done i’ll have to read docs on the subject…

dmesg showed an error loading GuC firmware :

[    4.174843] i915 0000:00:10.0: [drm] *ERROR* GT0: GuC firmware i915/tgl_guc_70.bin: fetch failed -ENOENT
[    4.175621] i915 0000:00:10.0: [drm] GT0: GuC firmware(s) can be downloaded from https://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git/tree/i915
[    4.176286] i915 0000:00:10.0: [drm] GT0: GuC firmware i915/tgl_guc_70.bin version 0.0.0
[    4.176350] i915 0000:00:10.0: [drm] *ERROR* GT0: GuC initialization failed -ENOENT
[    4.176977] i915 0000:00:10.0: [drm] *ERROR* GT0: Enabling uc failed (-5)
[    4.177502] i915 0000:00:10.0: [drm] *ERROR* GT0: Failed to initialize GPU, declaring it wedged!

I tried only setting i915.enable_guc boot param but it did not work, i had to also set hardware.enableAllFirmware to true. I now have a working config, not changing anything else :

    boot.kernelParams = [ "i915.force_probe=46d1,i915.enable_guc=3" ];
    systemd.services.jellyfin.environment.LIBVA_DRIVER_NAME = "iHD";
    environment = {
      sessionVariables = { LIBVA_DRIVER_NAME = "iHD"; };
      systemPackages = with pkgs; [
        cifs-utils
      ];
    };
    # Intel Hardware Acceleration config
    hardware = {
      enableAllFirmware = true;
      intel-gpu-tools.enable = true;
      graphics = {
        enable = true;
        extraPackages = with pkgs; [
          intel-media-driver
          vaapiVdpau
          intel-compute-runtime # OpenCL filter support (hardware tonemapping and subtitle burn-in)
          intel-ocl
          vpl-gpu-rt # QSV on 11th gen or newer
        ];
        extraPackages32 = with pkgs.pkgsi686Linux; [
          intel-media-driver
        ];
      };
    };
    services = {
[...]
      jellyfin= {
        enable = true;
        user = "tbarnouin";
        openFirewall = true;
      };
    };

I don’t understand why those i915 params changes anything : am i not suppose to use the iHD driver ?

Sorry for my lack of understanding as i don’t know the subject deeply enough, obviously.

1 Like

No worries, I’m also just guessing :slight_smile:

i915 is the older Kernel module while xe is the newer. iHD is the userspace VAAPI driver, but I think it works with both Kernel modules.

I’m not sure how the Linux kernel selects between the kernel modules. On my i5-1240P, both modules are loaded, but I only see log messages from the i915 module. I don’t have any kernel parameters related to either module set.

Regarding your config, the two kernel parameters should be separate strings. I’m not sure if i915.enable_guc=3 even has any effect right now. It might just be parsed as an another argument for i915.force_probe.
My guess is that i915.enable_guc is probably not required, and the problem was the missing firmware all along.

EDIT: you can forget everything I said about the xe module. It’s only available since Linux kernel version 6.8, but NixOS 24.11 is still using Linux 6.6. I’m running NixOS unstable on my Notebook, which is why it’s showing up for me. But it’s still experimental, and won’t be used by default.

I just got confused because the Alder Lake iGPUs are branded as “Xe Graphics”, but that doesn’t mean you have to (or even should) use the xe kernel module.
Linux kernel module are just weird sometimes. I mean, “i915” is the name of some ancient Intel chipset, but the i915 kernel module supports modern day GPUs.

1 Like

I confirm that everything works great without the kernel parameters set.

Thanks a lot for everything, i know understand a lot more on how everything works :slight_smile:

2 Likes

Please consider contributing a section to the Jellyfin article on wiki.

1 Like