Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request - Plex LXC with Hardware Acceleration Support #8

Closed
relliky opened this issue Jan 12, 2022 · 28 comments
Closed

Feature Request - Plex LXC with Hardware Acceleration Support #8

relliky opened this issue Jan 12, 2022 · 28 comments
Assignees
Labels
💡 Feature Request Feature Request

Comments

@relliky
Copy link

relliky commented Jan 12, 2022

Hi, tteck. Thanks for creating this awesome repo! It has greatly helped my experience with HA on PVE as a newbie to PVE. Coming from a HAOS background in a Raspberry Pi, it has been quite challenging for me to debug the PVE HA VM booting problem and your script just make this so easy. Thanks very much.

I am also trying your Plex LXC script and it works great. It would be great if you would like to update the Plex script with hardware acceleration support at some point when you are free. But I cannot ask for more given this repo is so great.

I have done a bit research on my own and find these as useful reference:
https://forums.plex.tv/t/plex-hw-acceleration-in-lxc-container-anyone-with-success/219289/117
https://herold.space/proxmox-lxc-intel-quick-sync-for-plex/

I am also trying to get it working at my end but still need to learn a lot about PVE, linux and LXC. Hopefully I can get it working and send a pull request to you :)

@tteck tteck added the 💡 Feature Request Feature Request label Jan 12, 2022
@tteck
Copy link
Owner

tteck commented Jan 12, 2022

Currently I'm not running a Plex Media Server so, if you're willing to test and give feedback I'd appreciate it.
This is for Intel CPU’s, 2011 and newer.

Run the following in the Proxmox web shell (replace 106 with your Plex Media Server LXC ID)

bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/misc/plex_hardware_acceleration.sh)" -s 106

@tteck tteck self-assigned this Jan 12, 2022
@relliky
Copy link
Author

relliky commented Jan 12, 2022

Hi tteck, thanks for such a quick response and script! Unfortunately I can see that the plex server is still not using hardware acceleration as screenshot attached. If it uses Intel Quick Sync, it will show "Transcode(hw)" instead of "Transcode".
image

I am using your latest script - checked in about half an hour ago. I can confirm that the script has updated LXC conf file with the hardware acceleration config. So I thought that the problem may be because this container is an unprivileged LXC instead of a privileged LXC as stated in the link hardware acceleration would only work in a privileged LXC. See https://herold.space/proxmox-lxc-intel-quick-sync-for-plex/

Following this solution https://www.reddit.com/r/Proxmox/comments/irjylk/how_can_i_edit_an_unprivileged_container_to_make/, I have made the LXC privileged and reboot. And I can confirm the LXC is privileged using one of the checking mechanism. Unfortunately the Plex LXC is still not using Intel Quick Sync for hardware acceleration.

Let me know if you need me to provide any kind of logs as I don't know what to provide. Don't worry too much if you don't have time. In the meantime, I will do more research on internet to see if I can find other things to try. But this is not blocking anything anyway, I just want to see if hardware acceleration in PVE can enable me to transcode 4k video or not or stream more video etc.

@tteck
Copy link
Owner

tteck commented Jan 12, 2022

Thanks, In your LXC conf file change to match below, reboot the LXC and give feedback

lxc.mount.entry: /dev/dri/renderD128 dev/dri/renderD128 none bind,optional,create=file 0, 0
lxc.mount.entry: /dev/dri/card0 dev/dri/card0 none bind,optional,create=file 0, 0
#lxc.mount.entry: /dev/dri dev/dri none bind,optional,create=dir 0, 0
#lxc.mount.entry: /dev/fb0 dev/fb0 none bind,optional,create=file 0, 0

FYI, all of my scripts create privileged containers.

@relliky
Copy link
Author

relliky commented Jan 13, 2022

Ah, I didn't realise that. Yes, I can confirm all of containers created by your script are privileged already.

Unfortunately the hardware acceleration is still not working after the change you proposed. The plex setting is correct as well. But let me check if anything wrong with my account first on another windows Plex server first just to root out other potential problems - will report back tomorrow after I tried it a windows machine. Thanks very much, tteck.

@tteck
Copy link
Owner

tteck commented Jan 13, 2022

When you find time add this to the conf

lxc.cgroup2.devices.allow: a

I appreciate your help!

@relliky
Copy link
Author

relliky commented Jan 13, 2022

Nah, it's you who are helping me.

I have tried windows client with an older intel processor and hardware acceleration is working fine with my account. I can also confirm the same transcode setting is used. I can see that my plex pass is working on my Samsung TV client as well because it can play trailers when I set it to.

Just tried to add the code you suggested and it didn't work either. So the conf files I tried just now are

<...the usual config...>
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.cgroup2.devices.allow: a
lxc.mount.entry: /dev/dri/renderD128 dev/dri/renderD128 none bind,optional,create=file 0, 0
lxc.mount.entry: /dev/dri/card0 dev/dri/card0 none bind,optional,create=file 0, 0

and

<...the usual config...>
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.cgroup2.devices.allow: a
lxc.mount.entry: /dev/dri dev/dri none bind,optional,create=dir 0, 0
lxc.mount.entry: /dev/fb0 dev/fb0 none bind,optional,create=file 0, 0

Will go to sleep now but let me know if you want me to try anything else or dump any logs and I can do that tomorrow or later.

@tteck
Copy link
Owner

tteck commented Jan 13, 2022

I assume you've installed the Intel Graphics acceleration drivers? example: apt-get install i965-va-driver
https://forum.proxmox.com/threads/coffee-lake-xeon-e-2176-and-p630-support.48890/
https://forums.plex.tv/t/pms-installation-guide-when-using-a-proxmox-5-1-lxc-container/219728

@tteck
Copy link
Owner

tteck commented Jan 15, 2022

Are we still actively working toward Plex Hardware Acceleration Support?
Or did fresh drivers alleviate the issue?

@relliky
Copy link
Author

relliky commented Jan 16, 2022

Hi tteck, thanks for the reference. I didn't install the Intel Graphics acceleration drivers. With the reference you gave, I managed to install that. But it didn't enable hardware transcode either. I am searching more information from internet as well and try to understand more to see if I can troubleshoot further from my end.

https://forums.plex.tv/t/pms-installation-guide-when-using-a-proxmox-5-1-lxc-container/219728 is guide for promox 5 while I am using proxmox 7. I wonder if any configuration need to be updated.

@zawias
Copy link

zawias commented Jan 17, 2022

@relliky - What's your CPU? I have the same problem. I am also unable to run hardware acceleration in Plex. I've tried everything and nothing. It seems to me that maybe my CPU is too old - Intel Core i7 4785T. And with you ?

@osaether
Copy link

For what it's worth: I run Plex with HW acceleration in LXC on two different machines and it works on both. One has Core i5-7400 and the other Core i5-11400.

@relliky
Copy link
Author

relliky commented Jan 22, 2022

Hi @zawias , @osaether thanks for the feedback. It's good to know that this is actually working and it is likely something wrong to my environment. I am running with Intel i5-5250U. According to intel website, both your i7-4785T and my i5-5250U features Intel Quick Sync Video.

https://ark.intel.com/content/www/us/en/ark/products/80814/intel-core-i74785t-processor-8m-cache-up-to-3-20-ghz.html
https://ark.intel.com/content/www/us/en/ark/products/84984/intel-core-i55250u-processor-3m-cache-up-to-2-70-ghz.html

I have spent another few hours today and haven't manage to get it working in Plex LXC.

I am planning to try the following when I have a bit more time:

  1. install PMS on an Ubuntu VM or LXC.
  2. Install different version of PMS

@osaether, could you confirm if you installed Plex LXC using tteck's script? I'd like to confirm the versions of linux LXC and PMS used by the script can work together to support hardware acceleration and root out a software compatibility problem. And do you mind also sharing your Proxmox VE version?

@osaether
Copy link

Hi @relliky, I did not install Plex using this script. I did it manually. One thing to check are the access modes for the /dev/dri folder in the container. I did these commands, before installing plex in the container:

/bin/chgrp video /dev/dri
/bin/chmod 755 /dev/dri
/bin/chmod 660 /dev/dri/*

@relliky
Copy link
Author

relliky commented Jan 23, 2022

Hi @osaether, thanks for the information. I already tried the command below and it didn't enable the hardware acceleration before.

/bin/chmod 755 /dev/dri
/bin/chmod 660 /dev/dri/*

I don't think change /dev/dri with video group would take any effect as I have given 755 permission on /dev/dri so its world and group permission are the same with 5 (r-x)

The only thing I haven't tried was to install plex after doing it. So I just tried it and it didn't work unfortunately.

I'd like to see if I can manually install Plex like what you did. When you have time, would it be okay for you to share the exact LXC you used and the versions you used and any reference to look for your installation if you happen to know?

@osaether
Copy link

Hi @relliky I described the steps I did on the proxmox forum (link below). I have since I wrote that post reinstalled following my own recipe but I had to do a few additional steps. First, the LCX container must be privileged. Then in the container shell I installed the intel drivers from the intel repo:
https://github.com/intel/compute-runtime/releases

and installed plexmediaserver.

Link to discussion on proxmox forum:
https://forum.proxmox.com/threads/intel-rocket-lake-11th-quicksync-passthrough.98874/#post-430464

@relliky
Copy link
Author

relliky commented Jan 23, 2022

Hi @osaether, thanks very much for the guide. I have managed to enable the hardware acceleration by using your installation method. FYI, @zawias, you may want to know that I have verified this installation method and you may use it as a workaround now.

@tteck, thanks for all the support and I really appreciated! I am suspecting the debian version and PMS version in your script had a compatibility issue when enabling hardware acceleration. I used @osaether's version and get it working on Ubuntu 20.04 and PMS repo. I am afraid that I don't think I am capable enough now to modify your script and send a pull request. But feel free to let me know if you need my help to verify your script when you are available to update the script.

@tteck
Copy link
Owner

tteck commented Jan 23, 2022

As you can see in the script

echo -e "${CHECKMARK} \e[1;92m Downloading Plex Media Server... \e[0m"
wget https://downloads.plex.tv/plex-media-server-new/1.25.3.5409-f11334058/debian/plexmediaserver_1.25.3.5409-f11334058_amd64.deb &>/dev/null
echo -e "${CHECKMARK} \e[1;92m Installing Plex Media Server... \e[0m"
sudo dpkg -i plexmediaserver_1.25.3.5409-f11334058_amd64.deb &>/dev/null

cat <<EOF > /etc/apt/sources.list.d/plexmediaserver.list
deb https://downloads.plex.tv/repo/deb/ public main
EOF

wget -q https://downloads.plex.tv/plex-keys/PlexSign.key -O - | sudo apt-key add - &>/dev/null

It's pulling the exact same PMS info/repo
I can setup the script to do everything that @osaether mentions, except install the intel drivers from the intel repo

@relliky
Copy link
Author

relliky commented Jan 23, 2022

@tteck , thanks for the clarification. Sure, that sounds a good starting point. I can help test it when you have the patch ready.

@tteck
Copy link
Owner

tteck commented Jan 23, 2022

@relliky ready for testing!

@osaether when you say "Then in the container shell I installed the intel drivers from the intel repo:" are you installing the drivers in the LXC container console? Not the Proxmox Shell.

@tteck
Copy link
Owner

tteck commented Jan 23, 2022

except install the intel drivers from the intel repo

I can create a seperate script to install the Intel drivers, but not in the PMS script, because not everyone is using Intel CPU's

@zawias
Copy link

zawias commented Jan 23, 2022

I checked it on other hardware with the i5-7500 CPU and it worked. I used the container from the script:
bash -c "$ (wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/plex_container.sh)"
then I executed a script from this thread:
bash -c "$ (wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/misc/plex_hardware_acceleration.sh)" -s 106.
After these steps, I only turned on acceleration in the server options. I didn't do anything else.
Before that, I installed a fresh Proxmox on a new computer and treated it with a script:
bash -c "$ (wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/misc/post_install.sh)"

Effect below:
image

@relliky
Copy link
Author

relliky commented Jan 23, 2022

@tteck I can confirm that I can enable the hardware acceleration using the latest script. Thanks for all the work to make beginners easier to use Proxmox.

I tested it using the command @zawias used. So I didn't install intel driver in the LXC and only did in the host. I haven't tested if I need to install intel driver in the host though. But I remember that /dev/dri/renderD128 and /dev/dri/card0 are visible to the host before I installed the intel graphics driver.

@zawias I think the latest script should work with your i7-4785T CPU as well.

@tteck
Copy link
Owner

tteck commented Jan 23, 2022

OK, here's where things stand
The script is using Ubuntu 20.04 (may go back to Debian 11)
Sets the .conf as follows

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/renderD128 dev/renderD128 none bind,optional,create=file

executes

/bin/chgrp video /dev/dri
/bin/chmod 755 /dev/dri
/bin/chmod 660 /dev/dri/*

before installing PMS
If need to install Intel Drivers run ./intel-drivers.sh from the console

@tteck
Copy link
Owner

tteck commented Jan 23, 2022

If someone will test to make sure everything is ok and working, I think we can call this complete! :)

@relliky
Copy link
Author

relliky commented Jan 23, 2022

@tteck, I think both zawias and I have tested it and it is working. Let me know if you are expecting to test with another sequence.

OK, here's where things stand The script is using Ubuntu 20.04 (may go back to Debian 11) Sets the .conf as follows

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/renderD128 dev/renderD128 none bind,optional,create=file

executes

/bin/chgrp video /dev/dri
/bin/chmod 755 /dev/dri
/bin/chmod 660 /dev/dri/*

before installing PMS If need to install Intel Drivers run ./intel-drivers.sh from the console

I think we may be able to remove a few lines of code here as some of them may not be required. Let me know if you prefers that, and I can try it out. But I can also understand the principle of "if it is working, don't change it" :)

@osaether
Copy link

osaether commented Jan 23, 2022

@osaether when you say "Then in the container shell I installed the intel drivers from the intel repo:" are you installing the drivers in the LXC container console? Not the Proxmox Shell.

Yes, I installed them in the LXC container console.

@tteck
Copy link
Owner

tteck commented Jan 23, 2022

Thanks everyone!

@tteck tteck closed this as completed Jan 23, 2022
@mushis
Copy link

mushis commented Aug 4, 2023

Hi, I'm struggling with hardware accel, it isn't working. I have an i5-7500T with onboard "gpu".
I installed though your script, and the lx.mount.entry lines are there, everything looks good.
lxc.cgroup2.devices.allow: a
lxc.cap.drop:
lxc.cgroup2.devices.allow: c 188:* rwm
lxc.cgroup2.devices.allow: c 189:* rwm
lxc.mount.entry: /dev/serial/by-id dev/serial/by-id none bind,optional,create=dir
lxc.mount.entry: /dev/ttyUSB0 dev/ttyUSB0 none bind,optional,create=file
lxc.mount.entry: /dev/ttyUSB1 dev/ttyUSB1 none bind,optional,create=file
lxc.mount.entry: /dev/ttyACM0 dev/ttyACM0 none bind,optional,create=file
lxc.mount.entry: /dev/ttyACM1 dev/ttyACM1 none bind,optional,create=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/dri/renderD128 none bind,optional,create=file

But it is very slow encoding/decoding, also 100% cpu. so the gpu-passthrough isn't working.

root@mushicenter:~# ls /dev/dri/ -la
total 0
drwxr-xr-x 3 root video 100 Aug 2 12:17 .
drwxr-xr-x 20 root root 4880 Aug 4 09:42 ..
drw-rw---- 2 root root 80 Aug 2 12:17 by-path
crw-rw---- 1 root video 226, 0 Aug 2 12:17 card0
crw-rw---- 1 root render 226, 128 Aug 2 12:17 renderD128

You mentioned:

If need to install Intel Drivers run ./intel-drivers.sh from the console

But I couldn't find this file.
Thanks in advance for any help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
💡 Feature Request Feature Request
Projects
None yet
Development

No branches or pull requests

5 participants