Activating Plex hardware acceleration

AlVal

Dabbler
Joined
Feb 16, 2012
Messages
15
I run older hardware .. but going to get ready for FreeNAS 12 with a Xeon E3-1245 that I'll pick up off of Ebay that supports Intel Quick Sync.. my current E3-1230 does not. I'll keep an eye on this thread
Just picked up an e3-1285l v4 for same purpose, that's the highest power one available for my socket type LGA1150 on my supermicro x10-sll mobo. Took some research to figure it out, the most helpful page was wiki here https://en.m.wikipedia.org/wiki/List_of_Intel_Broadwell-based_Xeon_microprocessors#Xeon_E3-1285L_v4
 

mrMuppet

Contributor
Joined
Mar 14, 2014
Messages
192
I found some instructions to use QuickSync with Plex on FreeNAS 11.3 installations with older Intel CPU Generation 2-7.
Freenas-Quicksync
 

toyebox

Explorer
Joined
Aug 20, 2016
Messages
87
I managed to get this to work today with my Xeon 1275v6 (intel p630). A few small differences though.

-I had to load the i915kms at the end of the sh script (editing the devfs rules first, restarting devfs service, and then i would load the driver).
-The dri and drm folders come up in the plexpass jail (I'm using the actual freenas plugin). As soon as i restart the jail for any reason, the dri/drm will not come back. I'm working on why this is, but i can restart the entire server and the jail will boot with dri/drm again.

even with the issue, i'm impressed it's actually working!

EDIT: in regard to my issue with dri/drm dissapearing after a jail restart, i have temporarily fixed it by creating a plain second jail(I named it DO_NOT_STOP) with a devfs_ruleset equal to the plex jail, ultimately loading dri/drm into both jails. When the plex jail is restarted, drm/dri is not lost because the plain jail is still retaining it. This will work for now at least.

EDIT 2: for my notes, and anyone else having the issue, if you have older mpeg4 files, mine would show up with a green tint over them (this is on the latest plex version 1.18.8 and older 1.18.3). i fixed it but renaming the iHD video driver to something different. I'm not entirely sure yet what plex is using instead though.

command: 'mv /usr/local/share/plexmediaserver-plexpass/lib/dri/iHD_drv_video.so /usr/local/share/plexmediaserver-plexpass/lib/dri/iHD_drv_video-not-yet.so'
 
Last edited:

Yorick

Wizard
Joined
Nov 4, 2018
Messages
1,912
Had a bear of a time with this, and got it to work. Intel Xeon 1225v6

FreeNAS 11.3-U1: /dev/dri did not show up on FreeNAS itself. Edit: I did this to myself. I had a compat.linuxkpi.modeset tunable with value 0, and while it had been disabled, that value "hung around". Setting it to "-1" had /dev/dri show up, and now hw transcode works in Plex 1.18.8 on 11.3U1, as well.

FreeNAS 12.0-nightly-0312: /dev/dri does show up on FreeNAS itself. Note this breaks IPMI KVM, and I haven't found a way around that. A LOADER tunable with compat.linuxkpi.i915_modeset and value 0 will keep IPMI as output, but then /dev/dri isn't present.

Nightly is profoundly unstable of course. I went there out of curiosity, since 11.3 didn't load the drivers for my iGPU - turns out I needed a better modeset tunable, not 12.0. Learn something every day.

/dev/dri would show up in the jail, but Plex 1.18.3 didn't use hw transcode.
I upgraded plex to 1.18.8 and now hw transcode works.
I may need to go and install plex in a regular jail, not a plugin, if I want to keep using hw transcode, so the intel media pkg doesn't disappear itself on update.

I played around with kld_list tunable. That probably would work, but for now I am doing what @toyebox suggests: service devfs restart and kldload after that, in the script.

Where previously Plex took 100% CPU to transcode a 4k video, now it takes 4% or thereabouts. Quality seems to be okay, though HDR to SDR transcoding is never going to be great. I'll still opt to store a 1080p native file where I have one.
 
Last edited:

toyebox

Explorer
Joined
Aug 20, 2016
Messages
87
Had a bear of a time with this, and got it to work. Intel Xeon 1225v6

FreeNAS 11.3-U1: /dev/dri did not show up on FreeNAS itself. Edit: I did this to myself. I had a compat.linuxkpi.modeset tunable with value 0, and while it had been disabled, that value "hung around". Setting it to "-1" had /dev/dri show up, and now hw transcode works in Plex 1.18.8 on 11.3U1, as well.

FreeNAS 12.0-nightly-0312: /dev/dri does show up on FreeNAS itself. Note this breaks IPMI KVM, and I haven't found a way around that. A LOADER tunable with compat.linuxkpi.i915_modeset and value 0 will keep IPMI as output, but then /dev/dri isn't present.

Nightly is profoundly unstable of course. I went there out of curiosity, since 11.3 didn't load the drivers for my iGPU - turns out I needed a better modeset tunable, not 12.0. Learn something every day.

/dev/dri would show up in the jail, but Plex 1.18.3 didn't use hw transcode.
I upgraded plex to 1.18.8 and now hw transcode works.
I may need to go and install plex in a regular jail, not a plugin, if I want to keep using hw transcode, so the intel media pkg doesn't disappear itself on update.

I played around with kld_list tunable. That probably would work, but for now I am doing what @toyebox suggests: service devfs restart and kldload after that, in the script.

Where previously Plex took 100% CPU to transcode a 4k video, now it takes 4% or thereabouts. Quality seems to be okay, though HDR to SDR transcoding is never going to be great. I'll still opt to store a 1080p native file where I have one.

Do you have the same issue i do, where if you restart the jail, you lose dri and drm?
 

ornias

Wizard
Joined
Mar 6, 2020
Messages
1,458
Do you have the same issue i do, where if you restart the jail, you lose dri and drm?
It's a bug in how the current version of iocage handles devfs. Devfs in iocage has been overhauled in more recent versions/PR's so should be solved at least in TrueNAS Core (12).
 

toyebox

Explorer
Joined
Aug 20, 2016
Messages
87
It's a bug in how the current version of iocage handles devfs. Devfs in iocage has been overhauled in more recent versions/PR's so should be solved at least in TrueNAS Core (12).
Thanks for the reply. Utilizing the solution I provided, it works fine. I did notice that upon reboot of the Plex jail, I then have all of the system /dev available in the jail, which is obviously not right. It'll work for now.
 

Yorick

Wizard
Joined
Nov 4, 2018
Messages
1,912
Do you have the same issue i do, where if you restart the jail, you lose dri and drm?

Just tested this, and did an "iocage restart plex" on 11.3-U1. /dev/dri remains visible, and hw transcode still works.
 

zperetz

Dabbler
Joined
Dec 2, 2017
Messages
36
I played around with kld_list tunable. That probably would work, but for now I am doing what @toyebox suggests: service devfs restart and kldload after that, in the script.
drm_load in loader and kld_list in rc should give the result on reboot without additional work.
 

Yorick

Wizard
Joined
Nov 4, 2018
Messages
1,912
Yes, with the exception of the devfs rules. That will require a script, since there’s no provision in FreeNAS to supply custom ones. You can set the jail to use a specific ruleset but not provide the ruleset. It might have been such a corner case that the middleware was just never written for it.

At least that’s my limited understanding of it.
 

toyebox

Explorer
Joined
Aug 20, 2016
Messages
87
Just tested this, and did an "iocage restart plex" on 11.3-U1. /dev/dri remains visible, and hw transcode still works.

That's odd. Tried two fresh installs, and both do it for me--where the initial reboot of the machine all works fine, but as soon as I restart the jail, it disappears.
 

Yorick

Wizard
Joined
Nov 4, 2018
Messages
1,912
It is odd. I just tested this again, same thing. Output below. We have different hardware - maybe there's something about that ASRock or that Xeon that triggers the bug.

Code:
root@freenas[~]# iocage exec Plex ls /dev/dri
card0           renderD128
root@freenas[~]# iocage restart Plex
* Stopping Plex-Transcode
  + Executing prestop OK
  + Stopping services OK
  + Tearing down VNET OK
  + Removing devfs_ruleset: 5 OK
  + Removing jail process OK
  + Executing poststop OK
* Starting Plex-Transcode
  Plex-Transcode is not using the devfs_ruleset of 4, not generating a ruleset for the jail, DHCP may not work.
  + Started OK
  + Using devfs_ruleset: 5
  + Configuring VNET OK
  + Using IP options: vnet
  + Starting services OK
  + Executing poststart OK
  + DHCP Address: 192.168.3.10/24
root@freenas[~]# iocage exec Plex ls /dev/dri
card0           renderD128
 

zperetz

Dabbler
Joined
Dec 2, 2017
Messages
36
EDIT 2: for my notes, and anyone else having the issue, if you have older mpeg4 files, mine would show up with a green tint over them (this is on the latest plex version 1.18.8 and older 1.18.3). i fixed it but renaming the iHD video driver to something different. I'm not entirely sure yet what plex is using instead though.

command: 'mv /usr/local/share/plexmediaserver-plexpass/lib/dri/iHD_drv_video.so /usr/local/share/plexmediaserver-plexpass/lib/dri/iHD_drv_video-not-yet.so'
It's pure library issue and pain in the ass, actually, I don't know working solution for the moment. Renaming lib you just forcing PMS to use software transcoding. In this case better to turn off "HW video encoding" in Transcoding section. At least you will have half of the process working with hw.
 

toyebox

Explorer
Joined
Aug 20, 2016
Messages
87
It's pure library issue and pain in the ass, actually, I don't know working solution for the moment. Renaming lib you just forcing PMS to use software transcoding. In this case better to turn off "HW video encoding" in Transcoding section. At least you will have half of the process working with hw.

I figured it had some sort of impact like that, but I did testing afterwards and that's not what it's doing. I just tried multiple 4k files that should of destroyed my cpu, but my usage stayed down below 10%. All seems to still work the same.
 

zperetz

Dabbler
Joined
Dec 2, 2017
Messages
36
I figured it had some sort of impact like that, but I did testing afterwards and that's not what it's doing. I just tried multiple 4k files that should have destroyed my cpu, but my usage stayed down below 10%. All seems to still work the same.
You have some magic or undocumented feature there, but for me it's working as lib issue: rename to '..not yet.so' and restart PMS - no-lib behavior with CPU load.
 

toyebox

Explorer
Joined
Aug 20, 2016
Messages
87
I'll go through and document tomorrow morning. I know for sure it wouldn't work if HW both encoding and decoding wasn't working, because I tried it on ESXi with only 1 cpu assigned lol. No possible way it's going to transcode a HEVC 10-bit 4k file ha. Like I said, I'll try and see if I can figure out how.
 

mattragusa

Cadet
Joined
Oct 28, 2018
Messages
8
I've been fighting with this for two days. I'm not especially familiar with FreeNAS beyond what I can do in the GUI or following directions.

I can't get dri or drm to show up in the jail, and I've gone through this conversation many times and tried to follow along.

My PMS lives by itself in a jail called EventHorizon. I would be very grateful for detailed directions on how to accomplish what is being discussed in here.
 

Yorick

Wizard
Joined
Nov 4, 2018
Messages
1,912
The detailed instructions are in the link in post 42.

What version of FreeNAS are you running, and which CPU? Motherboard?

To troubleshoot, you’d look at:
- Does /dev/dri show up in FreeNAS?
- If not, walk through “hardware supported”, “BIOS set right”, “correct driver for hardware loaded”, “right FreeBSD version”, “modeset isn’t interfering”
- If it does, it’s on to the jail: Rules correctly formed, devfs restarted after, right FreeBSD version, jail references the right rules, jail is set to allow that kind of passthrough.

The script is meant to make the devfs rule edit and devfs restart happen on boot, though it is missing the restart command. Unclear to me whether devfs is already up at that point, I admit I haven’t tested the script in its original version. I might, just “because”.
Update: Test complete. kldload at top of script kept my FreeNAS UI from loading; and devfs service does need to be restarted in the script. I forked the instructions and issued a PR with those changes.
 
Last edited:

zperetz

Dabbler
Joined
Dec 2, 2017
Messages
36
The script is meant to make the devfs rule edit and devfs restart happen on boot, though it is missing the restart command. Unclear to me whether devfs is already up at that point, I admit I haven’t tested the script in its original version. I might, just “because”.
Update: Test complete. kldload at top of script kept my FreeNAS UI from loading; and devfs service does need to be restarted in the script. I forked the instructions and issued a PR with those changes.
devfs is already up on post-init stage. But I prefer to load video drivers in tunables, not in custom script, to be sure the jail is not up yet. Also, in my case the rule number 5 or 9 was not working after 101, so I had to make it 110.
 
Top