[TUTORIAL] Plex + hw transcoding, LXC and Jasper Lake iGPU passthru

quenthal

Member
Oct 5, 2022
3
3
8
I finally managed to make hw transcoding work with Proxmox and Plex in an LXC container with Jasper Lake CPU. This has always been relatively easy with other hardware, but these Jasper Lake CPU’s (N5105, N6005 etc.) have been causing me headaches previously. But no more! :)
(Basically this is a combination of many discussions within this forum, some chinese forums and Plex's forums.)

1. Update kernel within Proxmox host to 5.19:
apt update apt install pve-kernel-5.19

2. Avoid simplefb claiming iGPU:
nano /etc/default/grub
add initcall_blacklist=sysfb_init
within GRUB_CMDLINE_LINUX_DEFAULT after quiet

3. Enable GUC in Proxmox host:
echo “options i915 enable_guc=2” >> /etc/modprobe.d/i915.conf

4. Download missing ehl_gux_70.1.1.bin to /lib/firmware/i915 within Proxmox host:
cd /lib/firmware/i915 wget https://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git/plain/i915/ehl_guc_70.1.1.bin
Note: this may be unnecessary - I've had one installation where this file already existed, but also one where manual download was needed.

5. Make sure iGPU is passed thru to LXC-container with following lines with it’s .conf -file:
lxc.cgroup2.devices.allow: c 226:0 rwm lxc.cgroup2.devices.allow: c 226:128 rwm lxc.cgroup2.devices.allow: c 29:0 rwm lxc.mount.entry: /dev/fb0 dev/fb0 none bind,optional,create=file lxc.mount.entry: /dev/dri dev/dri none bind,optional,create=dir lxc.mount.entry: /dev/dri/renderD128 dev/renderD128 none bind,optional,create=file

6. Within LXC-container enable GUC (maybe unnecessary):
echo “options i915 enable_guc=2” >> /etc/modprobe.d/i915.conf


7. Within LXC-container install Intel’s non-free drivers:
apt install intel-media-va-driver-non-free

8. Install latest Plex 1.29.x or higher, enable hw transcoding:
wget https://artifacts.plex.tv/plex-media-server-experimental/1.29.2.6273-2b xx xx x x.deb dpkg -i plexmediaserver_1.29.2.6273-2b xx xx x x.deb

Note: Enabling HDR tone-mapping may still cause “AVHWDeviceContext … No matching devices found.” error within Plex. This shouldn't be happening, however wven with N6005 the difference on CPU load with or without tone mapping with 4K HDR video is very low: 3-4% without tone mapping for single 4K movie, 5-7% with tone mapping on.
 
Last edited:
Thank you very much for your detailed tutorial. Just as a general hint, you can add the [Tutorial] prefix for posts like these - just select it from the drop down when you create a new post.

Step 6 should indeed be unnecessary - in a LXC container we share the kernel with the host, along with all loaded modules and their parameters ;).
 
  • Like
Reactions: quenthal
Thank you so much for the guide!

This got HW transcoding to work with HDR tone mapping. I'm running an Intel 12500. I ended up using pve-kernel-6.0-edge.
 
I have an N5105 box that I was able to get hardware acceleration up and running with full tone mapping.

Following all the steps in the guide worked well for regular hardware acceleration, but I was struggling to get tone mapping working. I eventually found the issue: my Plex configuration folder was migrated from a previous computer where I was running Plex in Docker. To get Plex to recognize the Intel drivers that support tone mapping I had to:

1. Delete the Drivers folder found in Library/Application Support/Plex Media Server
2. Restart Plex

After deleting my older Drivers folder, Plex recreated the folder with the correct Intel drivers and tone mapping worked wonderfully including indicating [hw] during playback.
 
I have an N5105 box that I was able to get hardware acceleration up and running with full tone mapping.

Following all the steps in the guide worked well for regular hardware acceleration, but I was struggling to get tone mapping working. I eventually found the issue: my Plex configuration folder was migrated from a previous computer where I was running Plex in Docker. To get Plex to recognize the Intel drivers that support tone mapping I had to:

1. Delete the Drivers folder found in Library/Application Support/Plex Media Server
2. Restart Plex

After deleting my older Drivers folder, Plex recreated the folder with the correct Intel drivers and tone mapping worked wonderfully including indicating [hw] during playback.
HW Tone mapping works for me as well, but I still get “AVHWDeviceContext … No matching devices found.” error within Plex log. Is this with your setup as well? (This error should mean that it is not working according to Plex, however this is clearly not the case in reality, since tone mapping is evidently working, and CPU usage is still low.)
 
Last edited:
HW Tone mapping works for me as well, but I still get “AVHWDeviceContext … No matching devices found.” error within Plex log. Is this with your setup as well? (This error should mean that it is not working according to Plex, however this is clearly not the case in reality, since tone mapping is evidently working, and CPU usage is still low.)
I checked my logs and I see the same AVHHWDeviceContext message.
 
  • Like
Reactions: Argiros
HW Tone mapping works for me as well, but I still get “AVHWDeviceContext … No matching devices found.” error within Plex log. Is this with your setup as well? (This error should mean that it is not working according to Plex, however this is clearly not the case in reality, since tone mapping is evidently working, and CPU usage is still low.)
Confirmed, this does work, but what a kludge
 
Thank you so much for the guide!

This got HW transcoding to work with HDR tone mapping. I'm running an Intel 12500. I ended up using pve-kernel-6.0-edge.
I'm curious what your cpu usage looks like when HDR tone mapping? I just followed this guide on a intel 13700 and while plex indicates (hw) transcoding when tone-mapping an h265 hdr10 video to sdr h264 and intel_gpu_top is showing a good amount of usage when run in the lxc container i'm still seeing about 50% cpu usage on one of the hosts P-Cores and about 30 watts extra being pulled at the outlet.

HW transcoding h264 to lower bitrate h264 shows basically 0 increase in cpu usage. Is this to be expected and perhaps caused by the [AVHWDeviceContext @ 0x7f9f4b79ed80] No matching devices found. error discussed by OP and others? I haven't been able to find much info out there on 12th/13th gen for this use case.
 
Came here to say thanks, and share my success in getting Plesk HW transcoding.

Beelink Intel N5105 16GB ram
Proxmox 7.3 (updating kernel as instructed in this thread)
LXC container running Ubuntu 22.04
CPU usage at 60% while HW transcoding a 4k movie & DVR recording live TV
GPU usage between 50% - 60% (looking at intel_gpu_top)
Memory hovers around 256, and I haven't seen it spike over 512

Note: I upgraded from hosting on an NVIDIA Shield, which had been working for years until I started adding live TV/DVR.
 
Any suggestions for running Plex with a 13th Gen i9K? This is my first project once I'm done with my build. Thank you!
 
This thread is pretty specific to Jasper Lake CPUs.
A few steps will probably be different for Raptor Lake CPUs. Kernel support, drivers, etc.
 
edit: A way safer method is way down!

Since this is a fair recent topic, I'll add my 2 cent.

With unpriviledged containers you could run into permission issues.

Bash:
root@pve_7.4-3:~# ls -l /dev/dri
total 0
drwxr-xr-x 2 root root         80 Mar 29 15:40 by-path
crw-rw---- 1 root video  226,   0 Mar 29 15:40 card0
crw-rw---- 1 root render 226, 128 Mar 29 15:40 renderD128

In the LXC container:
Bash:
[root@arch-test dri]# ls -la /dev/dri
total 0
drwxr-xr-x 2 root   root         80 Mar 29 14:16 .
drwxr-xr-x 7 root   root        480 Mar 29 14:16 ..
crw-rw---- 1 nobody nobody 226,   0 Mar 29 13:40 card0
crw-rw---- 1 nobody nobody 226, 128 Mar 29 13:40 renderD128

In my case it's a AMD gpu.

vainfo error: `error: failed to initialize display`

A way to circumvent (not "secure", but it works):
Bash:
root@pve_7.4-3:~# chmod 666 /dev/dri/card0
root@pve_7.4-3:~# chmod 666 /dev/dri/renderD128
root@pve_7.4-3:~# ls -l /dev/dri
total 0
drwxr-xr-x 2 root root         80 Mar 29 15:40 by-path
crw-rw-rw- 1 root video  226,   0 Mar 29 15:40 card0
crw-rw-rw- 1 root render 226, 128 Mar 29 15:40 renderD128

After that I can access the decoding capabilities with vainfo.

Another way would be to add the required users (from the lxc container inside proxmox - mind the UID-/GID-mapping!) to the correct groups.
AFAIK you can't add numeric users/UIDs to a group, so that would really be a hassle to keep that working, that's why I decided for the "all permissions"-way.

-----------
edit: After thinking how it could be made safer, I decided to write a rather simple udev rule.
To keep it simple - chown both files to root of the LXC container e.g. `chown 100000:100000 /dev/dri/{card*,render*}`
To let it do automatically:
Code:
root@pve_7.4-3:~# cat /etc/udev/rules.d/60-drm-permissions.rules
#SUBSYSTEM=="drm", KERNEL=="card*", MODE="0666"
#SUBSYSTEM=="drm", KERNEL=="render*", MODE="0666"

SUBSYSTEM=="drm", KERNEL=="card*", OWNER="100000", GROUP="100000"
SUBSYSTEM=="drm", KERNEL=="render*", OWNER="100000", GROUP="100000"

It's up to you if you want to allow "everything" on those devices or just one specific LXC container (which is usually enough).
 
Last edited:
New to Proxmox - I'm trying to get my N6005 to transcode and the instructions here don't seem to work for me. I was wondering if anyone has this working with Proxmox 7.4 with the latest kernel 6.2? I'm wondering if I'll need to downgrade to 5.19 to get this to go. Thanks.

Execution of changes to the /etc/modprobe.d/i915.conf and update-initramfs -u results in the following error: libkmod: ERROR ../libkmod/libkmod-config.c:657 kmod_config_parse: /etc/modprobe.d/i915.conf line 1: ignoring bad line starting with '“options'
 
Last edited:

thanks to quenthal who started this thread​

i have done some optimization/cleanup but globally it does work

I have an intel NUC11 ATKPE002 (Pentium N6005, Jasper Lake, 4C/4T, 10 Watts TDP)
proxmox 7.4.3 kernel 6.2, plexmediaserver installed in CT101 (privileged container) over "Ubuntu 22.04.2 LTS"

== Within CT101 LXC ==

Bash:
apt install intel-media-va-driver-non-free
apt install plexmediaserver

uname -r
lscpu
lspci -k
/usr/lib/plexmediaserver/Plex\ Media\ Server --version
Code:
...
intel-media-va-driver-non-free is already the newest version (22.3.1+ds1-1ubuntu0.1)
...
PlexMediaServer install:   Intel i915 Hardware: Found
...
6.2.11-2-pve
...
Model name:  Intel(R) Pentium(R) Silver N6005 @ 2.00GHz
...
00:02.0 VGA compatible controller: Intel Corporation JasperLake [UHD Graphics] (rev 01)
        DeviceName: Intel(R) UHD Graphics Device
        Subsystem: Intel Corporation JasperLake [UHD Graphics]
        Kernel driver in use: i915
...
v1.32.1.6999-91e1e2e2c
...

Bash:
dmesg | grep i915
Code:
[    5.634665] i915 0000:00:02.0: [drm] VT-d active for gfx access
[    5.634699] i915 0000:00:02.0: vgaarb: deactivate vga console
[    5.634766] i915 0000:00:02.0: [drm] Using Transparent Hugepages
[    5.635882] i915 0000:00:02.0: vgaarb: changed VGA decodes: olddecodes=io+mem,decodes=io+mem:owns=io+mem
[    5.636707] mei_hdcp 0000:00:16.0-b638ab7e-94e2-4ea2-a552-d1c54b627f04: bound 0000:00:02.0 (ops i915_hdcp_component_ops [i915])
[    5.646239] i915 0000:00:02.0: [drm] Finished loading DMC firmware i915/icl_dmc_ver1_09.bin (v1.9)
[    5.785906] i915 0000:00:02.0: [drm] GuC firmware i915/ehl_guc_70.1.1.bin version 70.1.1
[    5.785918] i915 0000:00:02.0: [drm] HuC firmware i915/ehl_huc_9.0.0.bin version 9.0.0
[    5.802472] i915 0000:00:02.0: [drm] HuC authenticated
[    5.803007] i915 0000:00:02.0: [drm] GuC submission enabled
[    5.803046] i915 0000:00:02.0: [drm] GuC SLPC disabled
[    5.805288] [drm] Initialized i915 1.6.0 20201103 for 0000:00:02.0 on minor 0

== Within proxmox host ==

Bash:
lspci -nn
ls -la /dev/dri/
ls -la /dev/dri/by-path/

Code:
00:02.0 VGA compatible controller [0300]: Intel Corporation Device [8086:4e71] (rev 01)
...
drwxr-xr-x  3 root root        100 May 14 13:28 .
drwxr-xr-x 19 root root       5000 May 14 13:28 ..
drwxr-xr-x  2 root root         80 May 14 13:28 by-path
crw-rw----  1 root video  226,   0 May 14 13:28 card0
crw-rw----  1 root render 226, 128 May 14 13:28 renderD128
...
lrwxrwxrwx 1 root root   8 May 14 13:28 pci-0000:00:02.0-card -> ../card0
lrwxrwxrwx 1 root root  13 May 14 13:28 pci-0000:00:02.0-render -> ../renderD128

Bash:
nano /etc/pve/lxc/101.conf
Code:
...
lxc.apparmor.profile: unconfined
lxc.cgroup2.devices.allow: c 226:0 rwm
lxc.cgroup2.devices.allow: c 226:128 rwm
lxc.mount.entry: /dev/dri dev/dri none bind,optional,create=dir
lxc.mount.entry: /dev/dri/renderD128 dev/dri/renderD128 none bind,optional,create=file
lxc.mount.entry: /dev/dri/card0 dev/dri/card0 none bind,optional,create=file
...

Bash:
nano /etc/default/grub
Code:
...
GRUB_CMDLINE_LINUX_DEFAULT="intel_iommu=on"
...

Bash:
echo 'options i915 enable_guc=3' >> /etc/modprobe.d/i915.conf
echo 'options i915 enable_fbc=1' >> /etc/modprobe.d/i915.conf
update-initramfs -u
reboot

== Tests & Results ==

Example 1:


SCYjBn5l.png

Transcode 1080p -> 720p

Example 2:

GzlOHXtl.png

Original 2160p [65Mbps] Format: HEVC profile: Main 10@L5.1@High
Transcode to 1080p [10Mbps]
Server CPU : max 20%, average < 6%


the proof : it is working perfectly (obviously with a plex pass..) !!!
 
Last edited:
  • Like
Reactions: flgndrhs
Was wondering if anybody could help me out here, because I’m following all the instructions in this thread, the iGPU is recognized inside the LXC container, I have a Plex Pass but Plex just seems to refuse doing hardware transcoding here…

I double checked and enabled « Use Hardware Acceleration Encoding When Available » in the plex settings…

I’ve enabled iommu in the GRUB_DEFAULT, I edited the LXC conf file with the code as mentioned by Oliv3 in his previous post and it seems to me: the LXC container recognizes that I have this GPU…

Inside LXC container:

Bash:
uname -r
lscpu
lspci -k
/usr/lib/plexmediaserver/Plex\ Media\ Server --version
vainfo

Code:
6.2.16-3-pve
…
Model name:            Intel(R) Celeron(R) N5105 @ 2.00GHz
….
00:02.0 VGA compatible controller: Intel Corporation JasperLake [UHD Graphics] (rev 01)
        DeviceName: Onboard - Video
        Subsystem: Intel Corporation JasperLake [UHD Graphics]
        Kernel driver in use: i915
…
/usr/lib/plexmediaserver/Plex\ Media\ Server --version
…
libva info: VA-API version 1.17.0
libva info: Trying to open /usr/lib/x86_64-linux-gnu/dri/iHD_drv_video.so
libva info: Found init function __vaDriverInit_1_17
libva info: va_openDriver() returns 0
vainfo: VA-API version: 1.17 (libva 2.12.0)
vainfo: Driver version: Intel iHD driver for Intel(R) Gen Graphics - 23.1.2 ()

Anybody who has the same issue? Am I doing something wrong here?
 

Attachments

  • ▶ House - S6 · E2.png
    ▶ House - S6 · E2.png
    848.3 KB · Views: 20
I have upgraded from proxmox 7 to 8 => hw transcoding working
I have installed a new proxmox 8 => hw transcoding NOT working

then i think I have the same issue
this is too "touchy", I am giving up
 
Mmm upgraded from Proxmox 7 to 8 as well... So not a new proxmox 8 install...

Allright I'll experiment a bit further then...
 
Last edited:
some news

fresh install of proxmox 8

I created a new LXC with tteck script from https://github.com/tteck/Proxmox
Bash:
bash -c "$(wget -qLO - https://github.com/tteck/Proxmox/raw/main/ct/plex.sh)"
  • Selected ubuntu 22.04 and privileged LXC
  • Overwrite /var/lib/mediaplayer from the previous installation
  • nothing else !
Code:
lspci -k

00:00.0 Host bridge: Intel Corporation Device 4e28
        Subsystem: Intel Corporation Device 3027

00:02.0 VGA compatible controller: Intel Corporation JasperLake [UHD Graphics] (rev 01)
        DeviceName: Intel(R) UHD Graphics Device
        Subsystem: Intel Corporation JasperLake [UHD Graphics]
        Kernel driver in use: i915

PLEX hw transcoding is working again
 
Last edited:
  • Like
Reactions: SlowmoDK
I can report that on fresh proxmox 8 with these mods installed acording to guide

echo “options i915 enable_guc=2” >> /etc/modprobe.d/i915.conf
echo 'options i915 enable_guc=3' >> /etc/modprobe.d/i915.conf
echo 'options i915 enable_fbc=1' >> /etc/modprobe.d/i915.conf
GRUB_CMDLINE_LINUX_DEFAULT="intel_iommu=on"

I created a new LXC with tteck script from https://github.com/tteck/Proxmox

Debian 12 privileged LXC

Plex HW transcode working out of box on N5105 with no need to modify the LXC conf

Thanks alot for pointing me in the right direction

Cheers
 
Last edited:

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!