Passthrough iGPU into LXC and activate Plex HW Transcode

Mặc định, Plex sẽ sử dụng CPU để chuyển mã và nó sẽ làm cho máy chủ Plex của bạn chậm lại vì tất cả các tài nguyên CPU có sẵn đều được sử dụng để chuyển mã.

1. Requirements

2. Passthrough iGPU to LXC Unprivileged

First of all, you need to activate IOMMU and iGPU for passthrough in my previous article.

Activate IOMMU and iGPU to Passthrough PCI into VM/CT

Verify that iGPU is detected and define major and minor numbers of iGPU.

  • In the Proxmox Server
1lspci -nnv | grep VGA

passthrough-igpu-01.png

1ls -l /dev/dri

passthrough-igpu-02.png

  • card0
    • major: 226
    • minor: 0
  • renderD128
    • major: 226
    • minor: 128

Open the LXC configuration and add the below to the config

1nano /etc/pve/lxc/<Container_ID>.conf
1lxc.cgroup2.devices.allow: c 226:0 rwm
2lxc.cgroup2.devices.allow: c 226:128 rwm
3lxc.mount.entry: /dev/dri/renderD128 dev/dri/renderD128 none bind,optional,create=file 0, 0
4lxc.mount.entry: /dev/dri dev/dri none bind,optional,create=dir

Now, the LXC Configuration will look like this

passthrough-igpu-03.png

After that, restart the LXC container to apply changes

1pct stop <Container_ID>
2pct start <Container_ID>

3. Verify iGPU is passthrough into LXC

SSH to the LXC and type the code below

1apt -y update
2apt -y install vainfo
3vainfo
 1root@plex:~# vainfo
 2error: can't connect to X server!
 3libva info: VA-API version 1.17.0
 4libva info: Trying to open /usr/lib/x86_64-linux-gnu/dri/iHD_drv_video.so
 5libva info: Found init function __vaDriverInit_1_17
 6libva info: va_openDriver() returns 0
 7vainfo: VA-API version: 1.17 (libva 2.12.0)
 8vainfo: Driver version: Intel iHD driver for Intel(R) Gen Graphics - 23.1.1 ()
 9vainfo: Supported profile and entrypoints
10      VAProfileMPEG2Simple            : VAEntrypointVLD
11      VAProfileMPEG2Main              : VAEntrypointVLD
12      VAProfileH264Main               : VAEntrypointVLD
13      VAProfileH264Main               : VAEntrypointEncSliceLP
14      VAProfileH264High               : VAEntrypointVLD
15      VAProfileH264High               : VAEntrypointEncSliceLP
16      VAProfileJPEGBaseline           : VAEntrypointVLD
17      VAProfileJPEGBaseline           : VAEntrypointEncPicture
18      VAProfileH264ConstrainedBaseline: VAEntrypointVLD
19      VAProfileH264ConstrainedBaseline: VAEntrypointEncSliceLP
20      VAProfileVP8Version0_3          : VAEntrypointVLD
21      VAProfileHEVCMain               : VAEntrypointVLD
22      VAProfileHEVCMain10             : VAEntrypointVLD
23      VAProfileVP9Profile0            : VAEntrypointVLD
24      VAProfileVP9Profile2            : VAEntrypointVLD

4. Setup hardware transcode on Plex Server

Go to your Plex Media Server —> Setting —> Transcoder —> Show Advanced.

  • [v] Use hardware acceleration when available
  • [v] Use hardware-accelerated video encoding

plex-transcode-01.png

5. Verify Plex using HW Transcode

On your PC or your phone. Play a random movie and choose the quality Convert to 1080p HD (High) or something.

plex-transcode-02.png

Go back to your Plex Dashboard, You will see the line Transcode (hw) in the Video Tab, That means Plex is using the Quick Sync function of iGPU to transcode the video.

And LXC Dashboard in Proxmox host, the CPU is not fulload 95% —> 100% anymore.

plex-transcode-04.png