tom472 / mediabox

Container based media tools configuration
MIT License
428 stars 83 forks source link

allow hardware acceleration by mapping the DRI device #73

Closed krishofmans closed 3 years ago

krishofmans commented 5 years ago

Hi,

Depending on the hardware in the machine, skylake, kaby lake etc there is support for hardware x26x encoding. By mapping the device it allows the plex docker container to use it.

HW acceleration still needs to be enabled from within plex: image

And can then be verified in the dashboard that HW decoding is actually being used: image

tom472 commented 5 years ago

Hey @krishofmans Thanks for the PR --

When you've added this mapping have you had to make any adjustments to the rights on the /dev/dri folder?

I took a look and saw people mentioning needing to chmod -R 777 the /dev/dri folder.

Did you need to take that step for this to work?

tom472 commented 5 years ago

@krishofmans Any chance you can stop back to this PR and check the questions I had above?

Thanks --Tom

krishofmans commented 5 years ago

Hi @tom472

Sorry for the delay, saw the first mail ... then something else came up and forgot to come back here.

This is a screenshot from the /dev/dri I'm using: image

I didn't have to change any permissions, this is on a Ubuntu 18.04.2 LTS but I don't know the state of this on all linux distro's.

It still requires a manual step in order to enable it in plex, and I don't know what docker would do if the permissions are wrong, if it would just not work in plex or if the container creation would fail. Because even if the dri device is mapped, if it's not supported by plex, it shouldn't matter as plex is smart enough to figure it out at runtime.

tom472 commented 5 years ago

Awesome - Thanks for stopping back and providing that info.

You touched on exactly what I am concerned about container creation failing should it not make the mapping.

I'll give it a shot on my test VPS see how it goes.

Thanks again for the PR and for playing with Mediabox.

tom472 commented 5 years ago

@krishofmans Sorry for the delay on getting to this. So I did test this on my VPS server and this addition does stop/break Plex from starting up if the directory does not exist.

I'll play around with testing for the directory and then adding in that mapping only if it exists but that will take some time since manipulating the docker-compose.yml file on the fly can be a bit risky.

Let me see what I can test and try out.

Thanks --Tom

krishofmans commented 5 years ago

No problem.

It would be ideal if there was some sort of templating/pre-parsing for the docker-compose file. Checking if the directory exists and turning it into a boolean is not a lot of work.

Just thinking out loud here: in the shellscript if /dev/dri exists we set that in the .env file to HW_ACCELL_DEVICE, otherwise we set it to /dev/null, it should exists and hopefully the plex detection will work then without docker-compose failing?

I can test that too if I have some spare time.

tom472 commented 5 years ago

That was kind of my thinking - check for the directory and if it exists then map /dev/dri and if it does not exist map /dev/null.

Just need to see if mapping host /dev/null to container /dev/dri still at least allows the Plex container to start up with out errors.

wibuf commented 4 years ago

Hey, just wondering if anyones been able to get GPU support with the plex docker? Thanks

krishofmans commented 4 years ago

@wibuf I'm still using it, mapping the DRI should work as long as your cpu is skylake or newer.

Update: I saw in the MR that you were using portainer, I have used it a long time ago, but I'm not sure if it has support for mapping devices, /dev/dri isn't just a volume.

wibuf commented 4 years ago

Ah okay, I have emby running on the same box with working hardware transcoding but its not in a container. I may need to stand plex up separately I guess. Thanks

krishofmans commented 4 years ago

It's definitely possible to get HW accel in a container, you don't even need the special nvidia support normally. It can just run off the cpu.

On Fri, Oct 25, 2019 at 3:53 PM wibuf notifications@github.com wrote:

Ah okay, I have emby running on the same box with working hardware transcoding but its not in a container. I may need to stand plex up separately I guess. Thanks

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/tom472/mediabox/pull/73?email_source=notifications&email_token=AAHUCXXWTFRHCVU2EOYIVL3QQL24RA5CNFSM4HMIZ4NKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOECINOLI#issuecomment-546363181, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAHUCXUZRF5AZYBG5BVZR6TQQL24RANCNFSM4HMIZ4NA .

wibuf commented 4 years ago

I need nvidia support, I got a dedicated p5000 I need to use. I've tried messing with the docker-composed and some other things but just wont take. I'll probably just bite the bullet and pull it off docker.

krishofmans commented 4 years ago

Apparently you will need the new transcoder: https://forums.plex.tv/t/hardware-accelerated-decode-nvidia-for-linux/233510/423 available since september, no hands on experience though.

On Fri, Oct 25, 2019 at 4:18 PM wibuf notifications@github.com wrote:

I need nvidia support, I got a dedicated p5000 I need to use. I've tried messing with the docker-composed and some other things but just wont take. I'll probably just bite the bullet and pull it off docker.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/tom472/mediabox/pull/73?email_source=notifications&email_token=AAHUCXXLTJD44577Q4CB353QQL52ZA5CNFSM4HMIZ4NKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOECIP4IA#issuecomment-546373152, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAHUCXTOD47Q6HVAKDJ7EVLQQL52ZANCNFSM4HMIZ4NA .