{"id":473,"date":"2024-05-25T11:40:26","date_gmt":"2024-05-25T19:40:26","guid":{"rendered":"https:\/\/nramkumar.org\/tech\/?p=473"},"modified":"2024-05-25T11:42:56","modified_gmt":"2024-05-25T19:42:56","slug":"using-hardware-acceleration-in-a-proxmox-plex-container","status":"publish","type":"post","link":"https:\/\/nramkumar.org\/tech\/blog\/2024\/05\/25\/using-hardware-acceleration-in-a-proxmox-plex-container\/","title":{"rendered":"Using hardware acceleration in a Proxmox Plex container"},"content":{"rendered":"\n<div class=\"wp-block-group is-vertical is-layout-flex wp-container-core-group-is-layout-4fc3f8e1 wp-block-group-is-layout-flex\">\n<div class=\"wp-block-group is-vertical is-layout-flex wp-container-core-group-is-layout-4fc3f8e1 wp-block-group-is-layout-flex\">\n<div class=\"wp-block-group is-vertical is-layout-flex wp-container-core-group-is-layout-4fc3f8e1 wp-block-group-is-layout-flex\">\n<p class=\"wp-block-paragraph\">Finally got around to fixing hardware acceleration on the plex container running in my proxmox server. These instructions work for Proxmox 8 and plex running in an unprivileged lxc container on debian (distribution should not matter, but I&#8217;m using Debian in the container).<br><br>To make hardware acceleration work, we need to accomplish two things:<\/p>\n\n\n\n<div class=\"wp-block-group is-vertical is-layout-flex wp-container-core-group-is-layout-4fc3f8e1 wp-block-group-is-layout-flex\">\n<ul class=\"wp-block-list\">\n<li>Pass the hardware rendering device to the container with appropriate privileges<\/li>\n\n\n\n<li>Allow mapping of plex group in the container to a group in the host that has access to the device<\/li>\n<\/ul>\n<\/div>\n<\/div>\n<\/div>\n\n\n\n<div class=\"wp-block-group is-vertical is-layout-flex wp-container-core-group-is-layout-4fc3f8e1 wp-block-group-is-layout-flex\">\n<p class=\"wp-block-paragraph\">For the second, the &#8220;render&#8221; group is what you want. <a href=\"https:\/\/gist.github.com\/packerdl\/a4887c30c38a0225204f451103d82ac5\">This excellent gist<\/a> has all the steps you need to follow in order to set this up. I took the step of doing what one of the comments in the gist suggested &#8211; namely, mapping the render group in the plex container to the render group in the host, instead of mapping the plex group in the plex container to the render group in the host. You will need the following information to get hardware acceleration in your unprivileged plex container:<\/p>\n\n\n\n<div class=\"wp-block-group is-vertical is-layout-flex wp-container-core-group-is-layout-4fc3f8e1 wp-block-group-is-layout-flex\">\n<ul class=\"wp-block-list\">\n<li>Group ID of &#8220;render&#8221; group in the plex container<\/li>\n\n\n\n<li>Group ID of &#8220;render&#8221; group in the host<\/li>\n<\/ul>\n<\/div>\n<\/div>\n\n\n\n<div class=\"wp-block-group is-vertical is-layout-flex wp-container-core-group-is-layout-4fc3f8e1 wp-block-group-is-layout-flex\">\n<div class=\"wp-block-group is-vertical is-layout-flex wp-container-core-group-is-layout-4fc3f8e1 wp-block-group-is-layout-flex\">\n<div class=\"wp-block-group is-vertical is-layout-flex wp-container-core-group-is-layout-4fc3f8e1 wp-block-group-is-layout-flex\">\n<p class=\"wp-block-paragraph\">Then you need to do the following:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Allow remapping of the &#8220;render&#8221; group in the host in containers &#8211; add the render group ID to <code>\/etc\/subgid<\/code><\/li>\n\n\n\n<li>Update the plex container configuration in proxmox to setup the remapping of the container &#8220;render&#8221; group to host &#8220;render&#8221; group. Edit <code>\/etc\/pve\/nodes\/server\/lxc\/container.conf<\/code> and add these lines where 106 is the group ID of &#8220;render&#8221; group in the container and &#8220;104&#8221; is the group ID of render in the host. The last line should start from lxc &#8220;render&#8221; group ID + 1 and the second number (65429) is basically 65535 &#8211; 107:<\/li>\n<\/ul>\n<\/div>\n\n\n\n<p class=\"wp-block-paragraph\"><code>lxc.idmap: u 0 100000 65536<br>lxc.idmap: g 0 100000 106<br>lxc.idmap: g 106 104 1<br>lxc.idmap: g 107 100107 65429<br><\/code><\/p>\n<\/div>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Finally, we need to pass the render device to the container and mount it, give permissions for the container to use the device. Add these lines to <code>\/etc\/pve\/nodes\/server\/lxc\/container.conf<\/code><\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><code>lxc.cgroup2.devices.allow: c 226:128 rwm<br>lxc.mount.entry: \/dev\/dri\/renderD128 dev\/dri\/renderD128 none bind,optional,create=file 0 0<br><\/code><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Where 228:128 come from the output of <code>ls -la \/dev\/dri<\/code> on the host &#8211; check the two numbers listed for the <code>render*<\/code> device and <code>\/dev\/dri\/renderD128<\/code> is the device that we are going to use for hardware acceleration which we find through <code>ls -la \/dev\/dri<\/code> as well.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Reboot the plex container and you should be using hardware acceleration for transcoding. You can check this by playing something that requires transcoding on another device and checking the plex web dashboard, expanding the playback details and see if you see Transcode (hw)<\/li>\n<\/ul>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Finally got around to fixing hardware acceleration on the plex container running in my proxmox server. These instructions work for Proxmox 8 and plex running in an unprivileged lxc container on debian (distribution should not matter, but I&#8217;m using Debian in the container). To make hardware acceleration work, we need to accomplish two things: For&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-473","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/nramkumar.org\/tech\/wp-json\/wp\/v2\/posts\/473","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/nramkumar.org\/tech\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/nramkumar.org\/tech\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/nramkumar.org\/tech\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/nramkumar.org\/tech\/wp-json\/wp\/v2\/comments?post=473"}],"version-history":[{"count":3,"href":"https:\/\/nramkumar.org\/tech\/wp-json\/wp\/v2\/posts\/473\/revisions"}],"predecessor-version":[{"id":480,"href":"https:\/\/nramkumar.org\/tech\/wp-json\/wp\/v2\/posts\/473\/revisions\/480"}],"wp:attachment":[{"href":"https:\/\/nramkumar.org\/tech\/wp-json\/wp\/v2\/media?parent=473"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/nramkumar.org\/tech\/wp-json\/wp\/v2\/categories?post=473"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/nramkumar.org\/tech\/wp-json\/wp\/v2\/tags?post=473"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}