<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>plex on Zexyen's Blog</title><link>https://zexyen.github.io/tags/plex.html</link><description>Recent content in plex on Zexyen's Blog</description><generator>Hugo -- gohugo.io</generator><language>en</language><atom:link href="https://zexyen.github.io/tags/plex/index.xml" rel="self" type="application/rss+xml"/><item><title>Passing through Intel Arc GPU to LXCs for Transcoding</title><link>https://zexyen.github.io/posts/arc-transcoding.html</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://zexyen.github.io/posts/arc-transcoding.html</guid><description>Foreword I have a Proxmox server where all of my homelab applications lives in, It&amp;rsquo;s super complicated with a bunch of random things just strung together in a semi-coherent fashion, but it works. I&amp;rsquo;m currently in the middle of doing a TV-esque broadcasting solution using ersatzTV, which is super cool if you want a continous TV Channel running in Plex. The issue with this however is that it&amp;rsquo;s a continously running FFMPEG stream, which if you scale it up and add more channels to it, will absolutely hammer your CPU.</description><content>&lt;h1 id="foreword">Foreword&lt;/h1>
&lt;p>I have a Proxmox server where all of my homelab applications lives in, It&amp;rsquo;s super complicated with a bunch of random things just strung together in a semi-coherent fashion, but it works. I&amp;rsquo;m currently in the middle of doing a TV-esque broadcasting solution using &lt;a href="https://ersatztv.org/">ersatzTV&lt;/a>, which is super cool if you want a continous TV Channel running in Plex. The issue with this however is that it&amp;rsquo;s a continously running FFMPEG stream, which if you scale it up and add more channels to it, will absolutely hammer your CPU. So I decided to buy a GPU &amp;amp; pass it through to the docker LXC containing it.&lt;/p>
&lt;h2 id="part-1-mistakes-were-made">Part 1: Mistakes were made&lt;/h2>
&lt;p>&lt;img src="../../images/huge_mistake.jpg" alt="Mistakes were made">
The proxmox server is running a Ryzen 5600G which was originally purchased with the idea of using the intergrated iGPU for Plex transcodes. Obviously that idea didn&amp;rsquo;t pan out because plex&amp;rsquo;s AMD GPU Support is severely lacking and it never properly worked, and since I never transcoded anyways because 90% of my streams were Direct Play I decided to just not bother dealing with it.&lt;/p>
&lt;p>In my infinite wisdom I thought that running an Intel Arc GPU Would be infinitely easier to deal with &amp;amp; cheaper than a NVIDIA GPU. &lt;em>I Was Wrong.&lt;/em>&lt;/p>
&lt;h3 id="part-2-living-with-your-mistakes">Part 2: Living with your Mistakes&lt;/h3>
&lt;p>I quickly figured out that the Arc GPU Support isn&amp;rsquo;t in Linux native till the 6.1 Kernel, which Proxmox thankfully has as a opt-in option for their kernel. You can opt-in to 6.2 by going to your proxmox host&amp;rsquo;s Shell, and run the following commands:&lt;/p>
&lt;div class="collapsable-code">
&lt;input id="1" type="checkbox" />
&lt;label for="1">
&lt;span class="collapsable-code__language">Terminal&lt;/span>
&lt;span class="collapsable-code__title">PVE Kernel Update&lt;/span>
&lt;span class="collapsable-code__toggle" data-label-expand="Show" data-label-collapse="Hide">&lt;/span>
&lt;/label>
&lt;pre class="language-Terminal" >&lt;code>
apt update
apt install pve-kernel-6.2
reboot
&lt;/code>&lt;/pre>
&lt;/div>
&lt;p>and now were in 6.2!&lt;/p>
&lt;p>Next we are going to want to figure out the &lt;code>/dev/dri&lt;/code> numbers for the GPU, which can be found by running &lt;code>ls -l /dev/dri&lt;/code> on your Shell. Below you can see that I got &lt;code>226, 0&lt;/code> &amp;amp; &lt;code>226, 128&lt;/code> respectively on mine.&lt;/p>
&lt;div class="collapsable-code">
&lt;input id="2" type="checkbox" />
&lt;label for="2">
&lt;span class="collapsable-code__language">terminal&lt;/span>
&lt;span class="collapsable-code__title">/dev/dri output&lt;/span>
&lt;span class="collapsable-code__toggle" data-label-expand="Hide" data-label-collapse="Hide">&lt;/span>
&lt;/label>
&lt;pre class="language-terminal" >&lt;code>
root@pve:~# ls -l /dev/dri
total 0
drwxr-xr-x 2 root root 80 Jun 3 11:41 by-path
crw-rw---- 1 root video 226, 0 Jun 3 11:41 card0
crw-rw---- 1 root render 226, 128 Jun 3 11:41 renderD128
&lt;/code>&lt;/pre>
&lt;/div>
&lt;p>Now that we have those numbers we can go ahead and pass it through to the LXC Containers, which you can do by editing &lt;code>/etc/pve/lxc/&amp;lt;id&amp;gt;.conf&lt;/code> and appending the following:&lt;/p>
&lt;pre tabindex="0">&lt;code>
lxc.cgroup2.devices.allow: c &amp;lt;numbers found earlier&amp;gt; rwm
lxc.cgroup2.devices.allow: c &amp;lt;numbers found earlier&amp;gt; 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
&lt;/code>&lt;/pre>&lt;p>It should come out like this example config:
&lt;div class="collapsable-code">
&lt;input id="3" type="checkbox" />
&lt;label for="3">
&lt;span class="collapsable-code__language">crlf&lt;/span>
&lt;span class="collapsable-code__title">Plex LXC Config&lt;/span>
&lt;span class="collapsable-code__toggle" data-label-expand="Hide" data-label-collapse="Hide">&lt;/span>
&lt;/label>
&lt;pre class="language-crlf" >&lt;code>
arch: amd64
cores: 12
features: mount=nfs;cifs,nesting=1
hostname: plex
memory: 3050
mp0: /mnt/pve/plex,mp=/media/plex
net0: name=eth0,bridge=vmbr0,gw=10.10.10.1,type=veth
onboot: 1
ostype: ubuntu
rootfs: local-lvm:vm-110-disk-0,size=151G
swap: 1536
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
&lt;/code>&lt;/pre>
&lt;/div>
&lt;/p>
&lt;p>And once you have that edited you can go ahead and restart the container.&lt;/p>
&lt;p>After Restarting you&amp;rsquo;re going to want to make sure that the User Plex runs under has access to your GPU by running &lt;code>gpasswd -a plex render&lt;/code> &amp;amp; &lt;code>gpasswd -a plex video&lt;/code> &lt;strong>In the container&lt;/strong>. You&amp;rsquo;ll know the GPU was properly passthrough (passthroughed?) when you run &lt;code>hwinfo --display&lt;/code> (which can be installed with &lt;code>apt-get install hwinfo&lt;/code> ) and see this as the output:&lt;/p>
&lt;div class="collapsable-code">
&lt;input id="4" type="checkbox" />
&lt;label for="4">
&lt;span class="collapsable-code__language">terminal&lt;/span>
&lt;span class="collapsable-code__title">hwinfo readout&lt;/span>
&lt;span class="collapsable-code__toggle" data-label-expand="Hide" data-label-collapse="Hide">&lt;/span>
&lt;/label>
&lt;pre class="language-terminal" >&lt;code>
root@plex:~# hwinfo --display
06: PCI 300.0: 0300 VGA compatible controller (VGA)
[Created at pci.386]
Unique ID: svHJ.28Q6RjwKYw7
Parent ID: GA8e.mr2N3fBJq5F
SysFS ID: /devices/pci0000:00/0000:00:01.1/0000:01:00.0/0000:02:01.0/0000:03:00.0
SysFS BusID: 0000:03:00.0
Hardware Class: graphics card
Model: &amp;#34;Intel VGA compatible controller&amp;#34;
Vendor: pci 0x8086 &amp;#34;Intel Corporation&amp;#34;
Device: pci 0x56a5
SubVendor: pci 0x1849 &amp;#34;ASRock Incorporation&amp;#34;
SubDevice: pci 0x6004
Revision: 0x05
Driver: &amp;#34;i915&amp;#34;
Driver Modules: &amp;#34;i915&amp;#34;
Memory Range: 0xfa000000-0xfaffffff (rw,non-prefetchable)
Memory Range: 0x7c00000000-0x7dffffffff (ro,non-prefetchable)
Memory Range: 0xfb000000-0xfb1fffff (ro,non-prefetchable,disabled)
IRQ: 119 (259700 events)
Module Alias: &amp;#34;pci:v00008086d000056A5sv00001849sd00006004bc03sc00i00&amp;#34;
Config Status: cfg=new, avail=yes, need=no, active=unknown
Attached to: #44 (PCI bridge)
Primary display adapter: #6
&lt;/code>&lt;/pre>
&lt;/div>
&lt;h4 id="part-3-how-i-learned-to-appreciate-what-i-have">Part 3: How I learned to appreciate what I have&lt;/h4>
&lt;p>Now in Plex you can go ahead and run any video through the WebUI, which should force it to transcode and you can confirm in the dashboard if it&amp;rsquo;s using your GPU or CPU.&lt;/p>
&lt;p>&lt;img src="https://images.zexyen.com/Images/2023/06-03/ZAzVA6.png" alt="Plex Dashboard HW Transcode">&lt;/p>
&lt;p>If it&amp;rsquo;s listing the transcode as &lt;code>Transcode (hw)&lt;/code> then congrats! It&amp;rsquo;s working.&lt;/p></content></item></channel></rss>