Activating Plex hardware acceleration

jonmayer

Cadet
Joined
Jan 20, 2017
Messages
9
Also, could you explain what the
[plex_drm=5] means in the /etc/devfs.rules ? Is plex_drm the iocage name? is the 5 the jail-ID?

The 5 refers to the ruleset number. If you go into your jails setup (hitting edit like below), there is a set of options under Jail Properties. the top most option is the devfs_ruleset. You can set this to a different number, but my experience was that it was always set to 5 (I only mentioned that offhand of my frustration, it may work perfectly for you as a different value).

freenas_jailprop.png

From the FreeNAS shell you can check with a command: iocage get devfs_ruleset <<your jail name>>. Anyway, loading the right ruleset is what allows the system to pass /dev/dri and /dev/drm to the jail. Passing this access on allows the jail to use the hardware. Whatever you can get to work, the number should match whatever value you give in /etc/devfs.rules which was labeleed [plex_drm=5] in my original post. This is easily verified by using ls /dev from the jail's shell. Like in my image, you should see dri and drm both listed.

freenas_jailshell.png

If you have drm and are missing dri, I found this from loading just the drm module and not the i915kms mod (I've read that there is also a different i915kms.ko depending on a newer or older CPU. If you have issues try loading just i915kms.ko instead of /boot/modules/i915kms.ko). If the user has been added to the right group, the multimedia driver installed, and these entries show up in /dev you should be good to go. Just remember to check the hardware encoding box in Plex as well.

You mentioned having a Kaby Lake processor. I've heard good things about the hardware encoder in these chips, so good luck. Mine looks like it has "extra jpeg" when viewed on anything larger than a phone. Although the load being roughly halved was nice.
 
Last edited:

TheRoss

Cadet
Joined
Oct 15, 2019
Messages
3
Wow! I thank you from the bottom of my heart for such detailed reply!
I understood everything you said.

Let me try to get this working and come back to you afterwards to show my result.
I'll be pleased to share my experience with my system in case someone else has the same CPU as mine :)
 

TheRoss

Cadet
Joined
Oct 15, 2019
Messages
3
Well, this is strange..
After each reboot, I have to switch repos from local to Freebsd, I have to install drm-kmod (it uninstalls the previously installed drm-next-kmod-4.11.g20180224), and I have to edit the configs.
Is there any reason why this is rolling back all the time after a reboot?
 

SparJar

Cadet
Joined
Oct 21, 2019
Messages
3
I have searched for a little while now and have come up short. Does anyone know if it's possible to use a dedicated GPU for hardware acceleration in Plex on FreeNAS? If it is, can you point me in the right direction?
 

ThreeDee

Guru
Joined
Jun 13, 2013
Messages
700
Edit: After playing with this on something other than mobile, the quality of the hardware encoder in these older CPUs is not great. I'll probably be turning off hardware encoding for any screen larger than 7 inches. I'm not upgrading anytime soon, but would love to see how well this works on a modern Intel processor.
so this would you use either or .. not both together?
 

Yorick

Wizard
Joined
Nov 4, 2018
Messages
1,912
I have searched for a little while now and have come up short. Does anyone know if it's possible to use a dedicated GPU for hardware acceleration in Plex on FreeNAS? If it is, can you point me in the right direction?

That’s not possible. All the efforts here are about getting hw acceleration to work with built-in Intel graphics.

NVIDIA support for hw transcode is available on Linux and Windows with Plex, but not on FreeBSD.
 

dak180

Patron
Joined
Nov 22, 2017
Messages
310
Aren't there NVIDIA drivers that work with FreeBSD?
It does not matter if plex does not support it; which it does not right now.
 

Yorick

Wizard
Joined
Nov 4, 2018
Messages
1,912
No luck so far with 11.3. Xeon v6 (Kaby lake), did a pkg install drm-kmod, and kldload /boot/modules/i915kms.ko . /dev/drm shows up, /dev/dri does not.

in 11.2 /dev/dri did show, so this has to be a FreeBSD issue. Dmesg shows errors about being unable to load the firmware - possibly related?

Do we have others in here with Kaby Lake who have tried loading drm-kmod kernel drivers and can speak to how that went?

Edit: Relevant bit of dmesg, see "GUC firmware load skipped"

Code:
drmn0: <drmn> on vgapci0
vgapci0: child drmn0 requested pci_enable_io
vgapci0: child drmn0 requested pci_enable_io
[drm] Memory usable by graphics device = 4096M
Failed to add WC MTRR for [0xc0000000-0xcfffffff]: -22; performance may suffer
[drm] Supports vblank timestamp caching Rev 2 (21.10.2013).
[drm] Driver supports precise vblank timestamp query.
[drm] DMC: load work fn start
i915/kbl_dmc_ver1_01.bin: could not load firmware image, error 2
[drm] Connector eDP-1: get mode from tunables:
[drm]   - kern.vt.fb.modes.eDP-1
[drm]   - kern.vt.fb.default_mode
i915/kbl_dmc_ver1_01.bin: could not load firmware image, error 2
[drm] failed to retrieve link info, disabling eDP
i915/kbl_huc_ver02_00.bin: could not load firmware image, error 2
[drm] Finished loading DMC firmware i915/kbl_dmc_ver1_01.bin (v1.1)
[drm] DMC: load work fn end
i915/kbl_huc_ver02_00.bin: could not load firmware image, error 2
[drm] GuC firmware load skipped
[drm] Initialized i915 1.6.0 20170123 for drmn0 on minor 0
[drm] Cannot find any crtc or sizes - going 1024x768
VT: Replacing driver "efifb" with new "fb".
start FB_INFO:
type=11 height=768 width=1024 depth=32
cmsize=16 size=3145728
pbase=0xc0040000 vbase=0xfffff800c0040000
name=drmn0 flags=0x0 stride=4096 bpp=32
cmap[0]=0 cmap[1]=7f0000 cmap[2]=7f00 cmap[3]=c4a000
end FB_INFO
drmn0: fb0: inteldrmfb frame buffer device
[drm] RC6 on


Relevant bit of lspci - Kaby Lake with built-in 630 GPU:

Code:
00:00.0 Host bridge: Intel Corporation Xeon E3-1200 v6/7th Gen Core Processor Host Bridge/DRAM Registers (rev 05)
00:02.0 Display controller: Intel Corporation HD Graphics P630 (rev 04)
 
Last edited:
Joined
Apr 8, 2017
Messages
10
I would love to know how this is coming along and what the commitment is on this issue. Are there active plans for IXsystems to bring support for NVDEC to FreeBSD? Or are they waiting until they move over to Linux (pending ZFS kinks are worked out)?

This is going to be my deciding factor between either staying with FreeNAS or going to UNRAID. I love my FreeNAS server right now and I'd love to keep it but the more important objective is ensuring that Plex is able to use my Nvidia P2000 GPU.
 

Yorick

Wizard
Joined
Nov 4, 2018
Messages
1,912
Chances of ixSystems developing a Plex feature on FreeBSD: Zero.

Plex itself will not use nvidia, or for that matter amd, acceleration on freebsd. All the Plex app supports is intel.

Freebsd has, to the best of my knowledge, always embraced Intel and amd, but not nvidia, who only supply binary blob Linux drivers.

If running Plex on your nas, and having it transcode there via hw, is your primary use case, then current state FreeNAS is not your best choice.
 

SweetAndLow

Sweet'NASty
Joined
Nov 6, 2013
Messages
6,421
I would love to know how this is coming along and what the commitment is on this issue. Are there active plans for IXsystems to bring support for NVDEC to FreeBSD? Or are they waiting until they move over to Linux (pending ZFS kinks are worked out)?

This is going to be my deciding factor between either staying with FreeNAS or going to UNRAID. I love my FreeNAS server right now and I'd love to keep it but the more important objective is ensuring that Plex is able to use my Nvidia P2000 GPU.
Is gpu transcoding even any good? I thought it was usually lower quality compared to cpu transcoding.
 
Joined
Apr 8, 2017
Messages
10
Is gpu transcoding even any good? I thought it was usually lower quality compared to cpu transcoding.

It's honestly amazing. You can effectively double, triple and sometimes quadruple your stream output. In addition, it free's up the CPU for doing other functions... like containers, VMs, plugin's, etc. There is some quality loss but if you are transcoding, you are already expecting a loss. I direct play in my house, only the family would see and loss and there is literally 0% chance they would notice. 2nd, the p2000 uses a fraction of the power to conduct the same task as a CPU so there is a significant savings in power consumption.

I've not seen quality testing for QuickSync but I would imagine it falls into the same bucket as Hardware Acceleration. Honestly, it's a no-brainer if you use Plex and have people that use it and/or want to use the server for something more than just a transcoding storage box.


 
Last edited:
Joined
Apr 8, 2017
Messages
10
Chances of ixSystems developing a Plex feature on FreeBSD: Zero.

Plex itself will not use nvidia, or for that matter amd, acceleration on freebsd. All the Plex app supports is intel.

Freebsd has, to the best of my knowledge, always embraced Intel and amd, but not nvidia, who only supply binary blob Linux drivers.

If running Plex on your nas, and having it transcode there via hw, is your primary use case, then current state FreeNAS is not your best choice.

Its all software so it can be done, it would just require someone high enough in each organization to make the business case and assign the issues to someone and resolve it. As you mentioned likelihood is probably not very high and you are probably correct. IMO reasons like this are why there has been a shift from FreeNAS to UnRaid. In the past years by much of the community and big streamers have switched to UnRaid already and they are releasing content and How-To's for UnRaid which is really powerful marketing! I don't go to a Ford dealer to find out if the Dodge is a good truck, I go to MotorTrend or Road and Track, etc. In this sense, Most people won't go to iXsystems to find out what the best solution is, they will seek the Tech channels for reviews and see what everyone is using and why. Even if you only consider Linus, he alone has 10million+ subscribers on Youtube, which has so much influence on the relevant community and market that FreeNAS operates. Hopefully, iXsystems catches on; Plex is a HUGE deal for a lot of the DIY Home PC community and would have some really large scale benefits to supporting this feature for the FreeNAS product. That's my 2c.
 

Yorick

Wizard
Joined
Nov 4, 2018
Messages
1,912
Oh I am convinced ixSystems has already caught on, hence the announcement that they are porting their middleware to Linux for some “yet to be announced products”. Will that be FreeNAS on Linux, by whatever name? That sounds like the most likely scenario to me.

You mention business case: I haven’t yet fully figured out the business case for FreeNAS. Maybe there are enough people buying hardware, maybe it’s just about name recognition and having a wider pool of technical people with ZFS experience. Naively, FreeNAS seems like not the most obvious business move, compared to TrueNAS - but given how committed ixsystems is to FreeNAS, I am clearly missing something.

I won’t be holding my breath for hw transcode for FreeNAS on FreeBSD, and see how the Linux efforts evolve throughout this year and next.
 

NeonB

Cadet
Joined
Jan 13, 2020
Messages
2
The 5 refers to the ruleset number. If you go into your jails setup (hitting edit like below), there is a set of options under Jail Properties. the top most option is the devfs_ruleset. You can set this to a different number, but my experience was that it was always set to 5 (I only mentioned that offhand of my frustration, it may work perfectly for you as a different value).

View attachment 33355

From the FreeNAS shell you can check with a command: iocage get devfs_ruleset <<your jail name>>. Anyway, loading the right ruleset is what allows the system to pass /dev/dri and /dev/drm to the jail. Passing this access on allows the jail to use the hardware. Whatever you can get to work, the number should match whatever value you give in /etc/devfs.rules which was labeleed [plex_drm=5] in my original post. This is easily verified by using ls /dev from the jail's shell. Like in my image, you should see dri and drm both listed.

View attachment 33356

If you have drm and are missing dri, I found this from loading just the drm module and not the i915kms mod (I've read that there is also a different i915kms.ko depending on a newer or older CPU. If you have issues try loading just i915kms.ko instead of /boot/modules/i915kms.ko). If the user has been added to the right group, the multimedia driver installed, and these entries show up in /dev you should be good to go. Just remember to check the hardware encoding box in Plex as well.

You mentioned having a Kaby Lake processor. I've heard good things about the hardware encoder in these chips, so good luck. Mine looks like it has "extra jpeg" when viewed on anything larger than a phone. Although the load being roughly halved was nice.
This really helped me a lot, I am so close. I have the devfs_ruleset working and I can see my dev folder from the jail but I can't get the /dev/dri folder to show up. I am using an i3 8100. The modules load fine and I've even tried using just i915kms.ko like you said but still nothing. The folder is just missing when I do "ls /dev" it doesn't come up. The modules seem to load fine but I suspect it isn't working.
 

faust7th

Cadet
Joined
Jan 31, 2020
Messages
4
Hello,

I believe that Intel Coffee Lake CPUs (Gen 8 and higher) with there UHD Graphics are not yet supported by the kernel module.
I think I have read that the "dri-next-kmod" only supports up to Gen 7 Intel Processors. (at the moment)

Please correct me if i am wrong, but this statement is also supported by my pciconf -lv output.
The Graphics card model is not detected as it usualy is (e.g. Intel UHD 620) and also my Processor is messed up. I have a "Pentium Gold G5400" in my system and not a "Xeon E3-1200 v5"

Code:
root@sloth[/]# pciconf -lv
hostb0@pci0:0:0:0:    class=0x060000 card=0x3e0f1849 chip=0x3e0f8086 rev=0x07 hdr=0x00
    vendor     = 'Intel Corporation'
    class      = bridge
    subclass   = HOST-PCI
pcib1@pci0:0:1:0:    class=0x060400 card=0x19011849 chip=0x19018086 rev=0x07 hdr=0x01
    vendor     = 'Intel Corporation'
    device     = 'Xeon E3-1200 v5/E3-1500 v5/6th Gen Core Processor PCIe Controller (x16)'
    class      = bridge
    subclass   = PCI-PCI
vgapci0@pci0:0:2:0:    class=0x030000 card=0x3e901849 chip=0x3e908086 rev=0x00 hdr=0x00
    vendor     = 'Intel Corporation'
    class      = display
    subclass   = VGA
......
......


So you Sir Mr. NeonB with your i3 8100 are also out of luck.
That is why the /dev/dri device is not even showing up in the FreeNAS Host and you can't pass it to your Jail.
btw. I am running version "11.3-RELEASE-p5".
 

NeonB

Cadet
Joined
Jan 13, 2020
Messages
2
Hello,

I believe that Intel Coffee Lake CPUs (Gen 8 and higher) with there UHD Graphics are not yet supported by the kernel module.
I think I have read that the "dri-next-kmod" only supports up to Gen 7 Intel Processors. (at the moment)

Please correct me if i am wrong, but this statement is also supported by my pciconf -lv output.
The Graphics card model is not detected as it usualy is (e.g. Intel UHD 620) and also my Processor is messed up. I have a "Pentium Gold G5400" in my system and not a "Xeon E3-1200 v5"

Code:
root@sloth[/]# pciconf -lv
hostb0@pci0:0:0:0:    class=0x060000 card=0x3e0f1849 chip=0x3e0f8086 rev=0x07 hdr=0x00
    vendor     = 'Intel Corporation'
    class      = bridge
    subclass   = HOST-PCI
pcib1@pci0:0:1:0:    class=0x060400 card=0x19011849 chip=0x19018086 rev=0x07 hdr=0x01
    vendor     = 'Intel Corporation'
    device     = 'Xeon E3-1200 v5/E3-1500 v5/6th Gen Core Processor PCIe Controller (x16)'
    class      = bridge
    subclass   = PCI-PCI
vgapci0@pci0:0:2:0:    class=0x030000 card=0x3e901849 chip=0x3e908086 rev=0x00 hdr=0x00
    vendor     = 'Intel Corporation'
    class      = display
    subclass   = VGA
......
......


So you Sir Mr. NeonB with your i3 8100 are also out of luck.
That is why the /dev/dri device is not even showing up in the FreeNAS Host and you can't pass it to your Jail.
btw. I am running version "11.3-RELEASE-p5".
This was the unfortunate conclusion I came to a few days ago. I moved my freenas install to an old Ivy Bridge computer I have so I can run Ubuntu and Plex on the i3 8100 until FreeNAS is updated to support it. I tried QuickSync on the old computer just out of curiosity and got it working pretty quickly. I get the same read out also about having a Xeon when it's a 8100.
 

Baenwort

Explorer
Joined
Feb 19, 2015
Messages
93
I added this to /etc/devfs.rules. I used ruleset 5 because no matter what I tried I couldn't get the jail to load any other ruleset, but it worked.
Code:
[devfsrules_bpfjail=101]
add path 'bpf*' unhide

[plex_drm=5]
add include $devfsrules_hide_all
add include $devfsrules_unhide_basic
add include $devfsrules_unhide_login
add include $devfsrules_jail
add include $devfsrules_bpfjail
add path 'dri*' unhide
add path 'dri/*' unhide
add path 'drm*' unhide
add path 'drm/*' unhide

So when FreeNAS reboots this addition is no longer in etc/devfs.rules and it is back to it's default.

Any suggestions on what I am forgetting?
 

dak180

Patron
Joined
Nov 22, 2017
Messages
310
So when FreeNAS reboots this addition is no longer in etc/devfs.rules and it is back to it's default.

Any suggestions on what I am forgetting?
  1. Setup a custom devfs rule set for the plex jail:

Save the following script somewhere:
Code:
#!/bin/sh

cat >>/etc/devfs.rules << 'EOF'

[devfsrules_bpfjail=101]
add path 'bpf*' unhide

[plex_drm=109]
add include $devfsrules_hide_all
add include $devfsrules_unhide_basic
add include $devfsrules_unhide_login
add include $devfsrules_jail
add include $devfsrules_bpfjail
add path 'dri*' unhide
add path 'dri/*' unhide
add path 'drm*' unhide
add path 'drm/*' unhide

EOF


service devfs restart
Set this to run as a postinit task. We do this rather than editing /etc/devfs.rules directly because it is regenerated on boot.

Finally you will need to edit the plex jail properties to set the devfs_ruleset to 109.
 
Top