Activating Plex hardware acceleration

AlVal

Dabbler
Joined
Feb 16, 2012
Messages
15
supermicro x10sll-f motherboard, went out and upgraded my cpu at considerable cost to a xeon e3-1285 v4 in order to avail of the best gpu-within-cpu that would fit in my x10sll-f. Expensive lesson learnt, after having read all the info in this post and done the appropriate things, I could see /dev/drm on the freenas host, but never /dev/dri. Turns out when dealing with xeon cpus , you need to be careful that you have a specific chipset on the motherboard, in my case i had intel c222 but apparantly i need a motherboard with intel c226 in order for quicksync to work - here are the links where i discovered this:



So I just spent another £100 on a secondhand x10slh-f which is similar to the x10sll-f apart from it has the required intel c226 chipset for supporting cpu integrated graphics. will update when it arrives and I start again..
 
Last edited:

Yorick

Wizard
Joined
Nov 4, 2018
Messages
1,912
Yes this is true, and it's easy to gloss over that like we did in this thread with "hardware supported?"

I'll issue another PR to the instructions. My understanding is you need:
- C226 - X10SLH-F and Intel S1200V3RPM confirmed
- C236 - X11SSH-F confirmed, X11SSM-F expected yes, ASRock Rack E3C236D2I confirmed, others TBD
- C246 - caveat board support. For example, X11SCH-F yes, X11SCM-F no. Also requires TrueNAS 12.x and hasn't been tested.

And board support, BIOS support. Which may not be a given, see C246.
 
Last edited:

kimtatt

Cadet
Joined
Mar 21, 2020
Messages
1
Hi there, I tried so many times, I can't get it work. Help needed...

======== INSIDE SYSTEM =========================================

root@freenas[~]# vainfo
error: XDG_RUNTIME_DIR not set in the environment.
error: can't connect to X server!
libva info: VA-API version 1.6.0
libva info: Trying to open /usr/local/lib/dri/iHD_drv_video.so
libva info: Found init function __vaDriverInit_1_6
libva info: va_openDriver() returns 0
vainfo: VA-API version: 1.6 (libva 2.6.0.0)
vainfo: Driver version: Intel iHD driver - 19.4.0
vainfo: Supported profile and entrypoints
VAProfileNone : VAEntrypointVideoProc
VAProfileNone : VAEntrypointStats
VAProfileMPEG2Simple : VAEntrypointVLD
VAProfileMPEG2Main : VAEntrypointVLD
VAProfileH264Main : VAEntrypointVLD
VAProfileH264Main : VAEntrypointEncSlice
VAProfileH264Main : VAEntrypointFEI
VAProfileH264Main : VAEntrypointEncSliceLP
VAProfileH264High : VAEntrypointVLD
VAProfileH264High : VAEntrypointEncSlice
VAProfileH264High : VAEntrypointFEI
VAProfileH264High : VAEntrypointEncSliceLP
VAProfileVC1Simple : VAEntrypointVLD
VAProfileVC1Main : VAEntrypointVLD
VAProfileVC1Advanced : VAEntrypointVLD
VAProfileJPEGBaseline : VAEntrypointVLD
VAProfileJPEGBaseline : VAEntrypointEncPicture
VAProfileH264ConstrainedBaseline: VAEntrypointVLD
VAProfileH264ConstrainedBaseline: VAEntrypointEncSlice
VAProfileH264ConstrainedBaseline: VAEntrypointFEI
VAProfileH264ConstrainedBaseline: VAEntrypointEncSliceLP
VAProfileVP8Version0_3 : VAEntrypointVLD
VAProfileHEVCMain : VAEntrypointVLD
VAProfileHEVCMain : VAEntrypointEncSlice
VAProfileHEVCMain : VAEntrypointFEI
VAProfileHEVCMain10 : VAEntrypointVLD
VAProfileVP9Profile0 : VAEntrypointVLD
root@freenas[~]#

========= INSIDE JAIL ===============================================================
root@embyJail:~ # ls -l /dev/dri/
total 0
lrw-rw---- 1 root video 8 Mar 21 19:08 card0 -> ../drm/0
lrw-rw---- 1 root video 10 Mar 21 19:08 renderD128 -> ../drm/128

root@embyJail:~ # ls -l /usr/local/lib/dri/
total 118400
-rwxr-xr-x 1 root wheel 4804784 Feb 1 03:20 hybrid_drv_video.so
lrwxr-xr-x 1 root wheel 17 Feb 1 04:17 i915_drv_video.so -> i965_drv_video.so
-rwxr-xr-x 1 root wheel 8226296 Feb 1 04:17 i965_drv_video.so
-rwxr-xr-x 1 root wheel 205127171 Mar 19 15:46 iHD_drv_video.so
lrwxr-xr-x 1 root wheel 18 Jan 31 08:21 nvidia_drv_video.so -> vdpau_drv_video.so

root@embyJail:~ # vainfo
error: XDG_RUNTIME_DIR not set in the environment.
error: can't connect to X server!
libva info: VA-API version 1.5.0
libva info: va_getDriverName() returns 0
libva info: Trying to open /usr/local/lib/dri/i965_drv_video.so
libva error: /usr/local/lib/dri/i965_drv_video.so has no function __vaDriverInit_1_0
libva info: va_openDriver() returns -1
vaInitialize failed with error code -1 (unknown libva error),exit

There no issue outside the Jail, but not in Jail.
Did anyone know how and why? Any help, I'm very appreciated. Thank you.
 

Yorick

Wizard
Joined
Nov 4, 2018
Messages
1,912
@kimtatt , you came over from the emby discussion thread at https://emby.media/community/index.php?/topic/70699-enable-hardware-acceleration-on-freebsd/page-3 . These two statements from that thread tell you everything you need to know:
"I'm on native FreeBSD. If it doesnt work there I doubt it will work on FreeNAS. I installed through FreeBSD ports."
and
"We're looking to hire someone from the FreeBSD community who can help us with this."

Let's open a new thread for Emby, where you can see how it'll behave in FreeNAS, after it works in FreeBSD to begin with. The thread can be a placeholder and a good reference for "current state in FreeBSD" until then. Let's leave this thread for the Plex discussion.
 

Yorick

Wizard
Joined
Nov 4, 2018
Messages
1,912
@dak180 Now that we have this working, there'll be more interest. Can you link the instructions from post #42 into your OP, a note that hardware acceleration on Plex requires purchasing a PlexPass, but does _not_ require to be on the plexmediaserver-plexpass beta code, and maybe a note that any troubleshooting will, at a minimum, require: Hardware, FreeNAS version, Plex version, ls /dev/dri on FreeNAS, ls /dev/dri in Plex iocage jail.
 

Yorick

Wizard
Joined
Nov 4, 2018
Messages
1,912
drm_load in loader and kld_list in rc should give the result on reboot without additional work.

I tested this today. drm_load is actually not needed, a kld_list alone suffices. It's a kld_list RC tunable with value "hwpmc t3_tom t4_tom /boot/modules/i915kms.ko".

There's something to be said for either approach. The advantage of having it in the script is that the user doesn't need to check the default value of kld_list for their specific version of FreeNAS. Even if kld_list changes, the script should continue working. The same can't be said for the tunable, it needs to be adapted if default kld_list changes. That said, a tunable can feel "cleaner", for sure.
 

ARRRRGGGGHHH

Dabbler
Joined
Mar 25, 2020
Messages
32
So my setup was working (other than some unrelated faulty memory) on a new hardware setup i have go as below.

MSIB150M Mobo.
Intel G4560 CPU
8Gb RAM.
Freenas 11.3-u1
Jails are 11.3-p7
Plex 1.18.8.2527

Not sure why it was working and now not. Tried redoing the jail. Can see dri/drm in both FreeNAS and the jail.

Tried without moving driver/files over but no dice (instructions on github wrong for 5th gen up for driver copy?).
Do these "notes" bit even matter?

And now i can't see dri/drm when i could before! ARGH!
 

Yorick

Wizard
Joined
Nov 4, 2018
Messages
1,912
The “notes” aren’t relevant. All you need is the script, and the relevant Intel drivers in your jail, installed via pkg, and a version of Plex that works with it all.
 

ARRRRGGGGHHH

Dabbler
Joined
Mar 25, 2020
Messages
32
The “notes” aren’t relevant. All you need is the script, and the relevant Intel drivers in your jail, installed via pkg, and a version of Plex that works with it all.
Good to know!

Reboot of my server sorted things. Frustrating!
 

ARRRRGGGGHHH

Dabbler
Joined
Mar 25, 2020
Messages
32
Hmmm... Broken again....

No changes made. May have restarted the jail a couple of times.

And now dri and drm are missing.

Will have to restart the machine again i suppose.

Can confirm restart of machine fixes issue.

Anything i can provide to try chase down what's going wrong?
 
Last edited:

Yorick

Wizard
Joined
Nov 4, 2018
Messages
1,912
You are likely running into the devfs bug that was mentioned earlier in the thread. The only way to avoid that bug, for now, is to keep the jail running after boot.
 

ARRRRGGGGHHH

Dabbler
Joined
Mar 25, 2020
Messages
32
You are likely running into the devfs bug that was mentioned earlier in the thread. The only way to avoid that bug, for now, is to keep the jail running after boot.
Ahh... Cheers!

Didn't notice the issue on my old hardware at all (Gen3 Intel to Gen7).

Will make sure i don't shut the jail down!

Issue is with FreeNAS itself?
 

listhor

Contributor
Joined
Mar 2, 2020
Messages
133
Just to confirm, where to install VAAPI drivers, in jail or in freenas? I don't see /dev/dri in neither of them... In my case I run freenas in VM with CPU passthrough. On the other hand, next to it there's Alpine (docker's host) VM and it has /dev/dri directory with its content. So I'm slowly leaning to run plex in docker container with hw support...
CPU as seen by FreeNAS:
Code:
CPU: Intel(R) Xeon(R) E-2278G CPU @ 3.40GHz (3408.00-MHz K8-class CPU)
  Origin="GenuineIntel"  Id=0x906ed  Family=0x6  Model=0x9e  Stepping=13
  Features=0xf8bfbff<FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CLFLUSH,MMX,FXSR,SSE,SSE2,SS>
  Features2=0xfffa3203<SSE3,PCLMULQDQ,SSSE3,FMA,CX16,PCID,SSE4.1,SSE4.2,x2APIC,MOVBE,POPCNT,TSCDLT,AESNI,XSAVE,OSXSAVE,AVX,F16C,RDRAND,HV>
  AMD Features=0x2c100800<SYSCALL,NX,Page1GB,RDTSCP,LM>
  AMD Features2=0x121<LAHF,ABM,Prefetch>
  Structured Extended Features=0x9c6fbb<FSGSBASE,TSCADJ,BMI1,HLE,AVX2,SMEP,BMI2,ERMS,INVPCID,RTM,NFPUSG,MPX,RDSEED,ADX,SMAP,CLFLUSHOPT>
  Structured Extended Features3=0xbc000400<MD_CLEAR,IBPB,STIBP,L1DFL,ARCH_CAP,SSBD>
  XSAVE Features=0xb<XSAVEOPT,XSAVEC,XSAVES>
  IA32_ARCH_CAPS=0x2b<RDCL_NO,IBRS_ALL,SKIP_L1DFL_VME>
  TSC: P-state invariant
 

ARRRRGGGGHHH

Dabbler
Joined
Mar 25, 2020
Messages
32
Just follow the instructions word for word and ignore the notes at the bottom.

Code:

From the Plex jail console:
  • Install the Intel graphics driver:
**For older CPUs - Intel GMA 4500 (GPU Gen 4) or newer (up to GPU Gen 7, CPU Core Gen 3/4 & Xeon v2/v3) ** pkg install multimedia/libva-intel-driver For newer CPUs - Intel HD 5000 (GPU Gen8 / CPU Core Gen 5 & Xeon v4) or newer Please note: Freenas currently (11.3-U1) does not include CPU Core Gen8 and Gen9 driver support pkg install multimedia/libva-intel-media-driver
  • add plex to the “video” group
pw groupmod -n video -m plex


You won't see drm/dri until you do the script and adjust the devfs rule on the jail. And may need to reboot the entire VM as well.
 

Yorick

Wizard
Joined
Nov 4, 2018
Messages
1,912
E-2278G: There is your answer. This is an 8th generation CPU and not supported by FreeBSD 11.3, as mentioned prominently at the very top of the instructions linked in post #42.
Edit: Whelp, I am causing misunderstandings elsethread with my sloppy language. The iGPU in Coffee Lake (Refresh) is not supported by drivers in FreeBSD 11.3, but is supported in FreeBSD 12.x. The CPU itself, without its iGPU functionality, works just fine in FreeNAS 11.3. Of course, I am thinking, but that’s not obvious to everyone, so I am editing this to be explicit.

At a minimum, you need to wait for TrueNAS Core 12, or test on that version now, fully understanding that it is not stable and you may not be able to revert to 11.3 from it.

No one has tested 8th gen CPUs in TrueNAS Core 12 for hw transcode in Plex. You’d be doing pioneering work. On a virtualized FreeNAS no less, which creates another layer of complexity.

If you are going to play with this, you need to start paying very close attention. That includes things like knowing which generation of CPU you are using, that a device not present on the host OS can obviously not be passed through into a jail, and seeing which console commands are run in according to the instructions. They do mention which console to be in, for each section.

Arguably, since you are virtualizing anyway, the easiest way for you to run Plex is in a Linux VM, accessing media storage via NFS.

@ARRRRGGGGHHH The issue you are running into is with a package in FreeBSD 11.3. This might be improved with FreeBSD 12.1, please see discussion earlier in the thread. This means the issue is present in FreeNAS 11.3, and potentially resolved in TrueNAS Core 12. No way to know for sure until that’s been tested. I don’t run into the bug in 11.3 (on a v6 Xeon - someone else does run into it on the same Kaby Lake generation), so I can’t test whether it’s resolved in 12.
I might do what you tried, and bounce Plex “a gazillion times” to see whether that allows me to reproduce the problem in 11.3.
 
Last edited:

ARRRRGGGGHHH

Dabbler
Joined
Mar 25, 2020
Messages
32
I might have only "bounced" it 2 or 3 times if that.
I read back a bit.

Good to know it's not just me and looks more like something to do with the hardware/software versions.

Maybe it's just 7th gen? (I don't want to give up my .265!)
 

listhor

Contributor
Joined
Mar 2, 2020
Messages
133
Thanks @ARRRRGGGGHHH and @Yorick
I'd read instructions but I wasn't aware of my CPU generation's number. So, I'll try plex in docker but there I face different issues (nothing is easy :) ) - docker is in the same runlevel with netmount and quite often starts too early. If I place netmount in boot runlevel then iscsi doesn't have enough time to start. I'm trying to figure out how to use "sleep" in docker's startup script...
 

Yorick

Wizard
Joined
Nov 4, 2018
Messages
1,912
@ARRRRGGGGHHH I've reproduced this on my 11.3, using a 7th gen Kaby Lake Xeon v6. Turns out I just needed to restart Plex a few times after boot to trigger the error. I then tested it on TrueNAS Core 12.0 nightly, and after 10 restarts, /dev/dri was still visible in the jail. Which means that sometime come summer, when 12.0 gets ready for release, we will have a fix. I have one more test to run, and, I expect the outcome will be the same.

@listhor Let's keep this thread for Plex hw transcode on FreeNAS, and: Take a look at https://www.datanovia.com/en/courses/docker-compose-wait-for-dependencies/ to do what you want. Then discuss that in a forum dedicated to docker, if you need further assistance.
 

ARRRRGGGGHHH

Dabbler
Joined
Mar 25, 2020
Messages
32
@Yorick awesome to hear!

I don't really see any need to restart my jails any more now that i have finished my cutover to new hardware but good to know and have out there that there is a small issue.

I have put in an "issue" on github about it.

I would have written something in but... I don't know how github works so i have no idea how to do anything other than an issue lol.

Thank you so much for your help and testing. I'll buy you some hand sanitiser and toilet paper (I'm from Australia...)
 

Yorick

Wizard
Joined
Nov 4, 2018
Messages
1,912
@ARRRRGGGGHHH Naw, buy yourself some beer, mate, and revel in misunderstood stereotypes of Australians while "putting a shrimp on the barbie". Reading into that, looks like you guys did that to yourselves in the 80s with a tourism commission ad. Cheers!
 
Top