Setting up Plex in an Unprivileged LXC Container on Proxmox 8.4 with Hardware Encoding
By Ward Pieters on
Running Plex in an unprivileged LXC container on Proxmox 8.4 with Intel Intel Quick Sync Video — or any GPU-accelerated hardware encoding — is a great way to maximize performance of your Plex server. This guide covers updating your kernel, configuring device permissions, and setting up Docker Compose for hardware acceleration.
1. Update Proxmox Kernel to 6.11
To ensure the best compatibility and performance with Intel Quick Sync, update your Proxmox host to kernel 6.11:
apt update && apt dist-upgrade
apt install proxmox-kernel-6.11
reboot
After rebooting, verify the kernel version:
uname -r
This should output something like: 6.11.x-pve.
2. Set Device Permissions for GPU Access
In order to use Intel Quick Sync, the LXC container needs access to the /dev/dri devices. For unprivileged LXC containers, you need to adjust permissions before passing through the device.
a. Set Kernel Parameter
Run the following command on the Proxmox host to allow access to performance counters. Add the following line to /etc/sysctl.conf to make this persistent:
kernel.perf_event_paranoid=0
Then reload sysctl settings:
sysctl -p
b. Create a udev Rule for /dev/dri
First, identify your GPU devices. You can do this by running:
ls /dev/dri
You should see devices like card0 and renderD128, which are used as an example in this guide. Create a new udev rule file to set the correct permissions for these devices:
nano /etc/udev/rules.d/99-dri-permissions.rules
Add the following lines:
KERNEL=="card0", SUBSYSTEM=="drm", MODE="0777"
KERNEL=="renderD128", SUBSYSTEM=="drm", MODE="0777"
Reload udev rules using below command, or reboot the Proxmox host:
udevadm control --reload-rules && udevadm trigger
3. Pass Through /dev/dri to the LXC Container
Shut down the LXC container if it is running. Edit your container's config file (e.g., /etc/pve/lxc/100.conf) and add the following lines to the end:
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/dri dev/dri none bind,optional,create=dir
lxc.mount.entry: /dev/dri/card0 dev/dri/card0 none bind,optional,create=file
lxc.mount.entry: /dev/dri/renderD128 dev/renderD128 none bind,optional,create=file
After editing the config file, start the LXC container again.
4. Add /dev/dri Mount to Docker Compose
In your Plex Docker Compose service, add the /dev/dri device to make the GPU available to the Plex container. A full working example is shown at the end of this guide.
services:
plex:
# ...other options...
devices:
- /dev/dri:/dev/dri
5. Verify Hardware Transcoding in Plex
Start your Plex container and check if hardware transcoding is enabled. You can do this by going to the Plex dashboard, navigating to Settings > Server > Transcoder, and looking for the "Use hardware acceleration when available" option.
If it is enabled, you should see (hw) next to the transcoder in the dashboard when playing a video that requires transcoding.
Problems?
This post has been written with the outmost care, but if you find any mistakes or have any suggestions, please let me know.
If you encounter any problems, check all the steps again and make sure you have followed them correctly.