Discussion HW transcoding from Docker - solution for Hetzner dedicated and info for other servers

timekills

Blitz Samurai
Original poster
Staff
Donor
397
167
NOTE: You MUST have Plex Pass to enable hardware transcoding in the Plex server. See Using Hardware-Accelerated Streaming from the Plex site.

NOTE 2: the default PlexGuide install for Plex now includes the pass through of the driver folders from the host server to the Docker container, making this process much simpler.
-------------------------------------------------------------------------------------

Background/quick check:

This assumes your server has a CPU with iGPU or GPU that can do hardware transcoding. If you do, and the drivers are already installed, then the fix to get it working inside the Plex Docker container isn't too difficult.

Bottom line up front: If the hardware and drivers aren't installed on the host, it won't work inside the Docker container. If they are, I'll show you how to ensure they're available inside the Docker container as well.

You can do a quick check to see if the drivers are already installed by "ls -la /dev/dri"; you should see something for "card0" and "renderD128" if they are.
--If you have multiple GPUs, including an integrated (iGPU) and a discrete (i.e. nVidia or AMD) you'll probably see additional files labeled "card1" and "renderD129". This won't matter, but we also will only use one card.
If the driver files don't exist you'll likely get an error saying the directory doesn't exist, or maybe drivers for other non-GPU/iGPU devices. That's fine - the "Host Install" sections will show you how to "activate" them.
If they are, and you're sure, you can skip the next part in between the dashed lines and move to how to enable inside the Docker container.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Does my Intel CPU include an iGPU capable of Quick Sync?

Most "desktop" class CPUs from Intel starting with the second series (i.e. "Sandy Bridge" or the 2500/2600 CPUs) have an iGPU that is capable of at least h264 hardware transcoding.

- The Sandy Bridge (2xxx series) through Haswell (4xxx) series don't have great quality when hardware transcoding h264 - but they do work.

- Skylake (6xxx) and higher will even do h265/HEVC.

- Kaby Lake (7xxx) and higher will do h265/HEVC with HDR/10bit video.

Skylake and higher look GREAT when using hardware encoding - virtually indistinguishable in quality from CPU encodes, but with 5% of the CPU usage.

I have a Xeon - will it work?
Some Xeons do have iGPUs. Notably those that end in a "5" or "6".

How can I confirm?
Fast check: https://ark.intel.com/Search/FeatureFilter?productType=processors&QuickSyncVideo=true
Search for your CPU.

or

https://en.wikipedia.org/wiki/Intel_Quick_Sync_Video#Microsoft_Windows

For example, using a Xeon E5-1650v3.
Look for the E5-1650v3 series. This is a "Haswell" class CPU, but it was sold as a workstation CPU so note there is no "Graphics Clock Rate" column, because they didn't have iGPUs. (They also didn't come with heatsinks, as the users were expected to add discrete GPUs and their own heatsink.)

---------------------------------------------------------------------------

Host Install (for Hetzner - may be useful for others as a guide):

For Hetzner server users, the following is how to get the drivers and capability installed on the Linux host.

1) Comment out all line referencing i915 in this file: /etc/modprobe.d/blacklist-hetzner.conf
1a. sudo nano /etc/modprobe.d/blacklist-hetzner.conf
1b. Add a # in front of the lines "blacklist i915" and "blacklist i915_bdw"
# blacklist i915
# blacklist i915_bdw


2) Remove Hetzner's default grub config "nomodeset" which blocks loading of video card drivers:
2a. Ubuntu 16 or earlier: nano /etc/default/grub.d/hetzner.cfg or
2b. Ubuntu 18.04 or later: nano /etc/default/grub
and comment out GRUB_CMDLINE_LINUX_DEFAULT="nomodeset" (i'ts okay if it also has consoleblank=0 at the end."
# GRUB_CMDLINE_LINUX_DEFAULT="nomodeset consoleblank=0"

3) Update and Reload grub.
3a. sudo update-grub
3b. For older Ubuntu try "sudo grub-mkconfig -o /boot/grub/grub.cfg"

4) Add user root (or whoever is the user running the Plex service) to the video group:
4a. sudo usermod -a -G video root

5) Reboot the server

6) Try ls -la /dev/dri now it should find the folder and list drivers

7) chmod -R 777 /dev/dri to change permissions (critical step for use in Docker!

8) I recommend installing and running vainfo and ensure it gives you a positive readout on your driver
8a. sudo apt update
8b. sudo apt install vainfo
8c. vainfo
- You want a line similar to "vainfo: Driver version: Intel i965 driver for Intel(R) Haswell Server - 1.7.0" somewhere in the 18-20 lines it puts out.

Note: If VAINFO works, it's almost a sure bet you'll be able to get the Docker Plex to work. However, as long as the /dev/dri folder with the two driver files are there, you're probably okay even if running VAINFO throws an error.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Getting it working (optimally) inside Docker.

The following updates to the Plex Docker container are not strictly necessary - but recommended.

You'll need to run the following commands from the HOST (to make it easier for you):
docker exec plex apt-get -y update

docker exec plex apt-get -y install i965-va-driver vainfo

docker restart plex

That updates the driver now that it can get to the files outside the container.

------------------------------------------------------------------------------------

Examples:

My Hetzner server CPU is an Intel Xeon E3-1246V3 so it can do x264 HW transcode, but not x265 (as far as my research can tell.) So no dice on the 4K in x265 video. But for x264...

Before the update:

Hetzner_Docker_HWtranscode_before.png

After the update:

Hetzner_Docker_HWtranscode_after.png

Notice the (hw) after the video transcoding. Hardware transcode!

-------------------------------------------------------------------------------------

Additional tips/tricks:

The following command should give a succinct info read on your iGPU:

GPU=$(lspci | grep VGA | cut -d ":" -f3);RAM=$(cardid=$(lspci | grep VGA |cut -d " " -f1);lspci -v -s $cardid | grep " prefetchable"| cut -d "=" -f2);echo $GPU $RAM

For example, on one of the dedicated servers I use (the one in the examples above), the output is:
Intel Corporation Xeon E3-1200 v3 Processor Integrated Graphics Controller (rev 06) 256M]

However on a non-dedicated VPS I use the output is:
Cirrus Logic GD 5446 32M]

(Yeah...the emulated Cirrus Logic ain't going to work.)

Credits

PlexGuide Wiki Article on enabling hardware driver install for Hetzner servers: https://plexguide.com/wikis/plex-hw/: @The Creator and @WildWayz

Original Article
Desimaniac: https://github.com/desimaniac/docs/blob/master/enable_igpu_on_hetzner.md
 
Last edited:

captngimpy

Blitz Sergeant
Staff
100
23
So I broke something. I added the directories into the plex.yml and it hung at the
TASK [Create plex directories]. So I figured it must be something with the fact that I was running and OLD version of PG so I upgraded to 7.013 (AWESOME NEW LOOK BTW) and now it is still hanging at the same spot. I kinda feel like i should have just added the directories in to through portainer directly but now this is where I'm at.

Removing the 2 lines and retrying it sat at that point for about 8 mins and then went through. So i canceled and added back in the two lines and it went on through. Not sure what the problem was guess i just needed to let it set.
 
Last edited:

timekills

Blitz Samurai
Original poster
Staff
Donor
397
167
So I broke something. I added the directories into the plex.yml and it hung at the
TASK [Create plex directories]. So I figured it must be something with the fact that I was running and OLD version of PG so I upgraded to 7.013 (AWESOME NEW LOOK BTW) and now it is still hanging at the same spot. I kinda feel like i should have just added the directories in to through portainer directly but now this is where I'm at.

Removing the 2 lines and retrying it sat at that point for about 8 mins and then went through. So i canceled and added back in the two lines and it went on through. Not sure what the problem was guess i just needed to let it set.
You can't pass through directories from host to container after the container is built. You have to do it upon creations of the container, so no - you couldn't add them in through Portainer.

How old a version Plexguide did you try to upgrade from? And I assume you meant you pulled my fork down and installed it when you say that?

One other thing - the plex.yml I included assumes you have the two directories I mentioned already existing in the host; i.e. you've already gone through the steps of ensuring the host can do hardware transcoding. Do/did you check that first?

Edit: Re-reading your post, I see you said " I added the directories into the plex.yml". The plex.yml where - your own fork?
 

captngimpy

Blitz Sergeant
Staff
100
23
By add i meant i could have hit the edit button and then it just creates a new container then i could have then added the directories. I just went into the plex.yml file locally and aded it then ran it from the installer. I ran into some other issues of my own like the server not reclaiming and then saying it was online but everyhting was gone. I got it sorted though.
 
  • Like
Reactions: timekills

kamos69

Blitz 1st Class
Donor
96
53
I had tried the tips on getting it working, and was able to get the server set up if I were running Plex natively on the host. But it never seemed to work inside the Plex Docker container. Until now...

This assumes your server has a CPU with iGPU or GPU that can do hardware transcoding. If you do, and the drivers are already installed, then the fix to get it working inside the Plex Docker container isn't too difficult.

Bottom line up front: If the hardware and drivers aren't installed on the host, it won't work inside the Docker container. If they are, I'll show you how to ensure they're available inside the Docker container as well.

You can do a quick check to see if the drivers are already installed by "ls -la /dev/dri"; you should see something for "card0" and "renderD128" if they are.
if they're not (yet), you'll likely get an error saying the directory doesn't exist, or maybe drivers for other non-GPU/iGPU devices.
If they are, and you're sure, you can skip the next part in between the dashed lines and move to how to enable inside the Docker container.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
For Hetzner server users, the following is how to get the drivers and capability installed on the Linux host.

1) Comment out all line referencing i915 in this file: /etc/modprobe.d/blacklist-hetzner.conf
1a. sudo nano /etc/modprobe.d/blacklist-hetzner.conf
1b. Add a # in front of the lines "blacklist i915" and "blacklist i915_bdw"
# blacklist i915
# blacklist i915_bdw


2) Remove Hetzner's default grub config "nomodeset" which blocks loading of video card drivers:
2a. Ubuntu 16 or earlier: nano /etc/default/grub.d/hetzner.cfg or
2b. Ubuntu 18.04 or later: nano /etc/default/grub
and comment out GRUB_CMDLINE_LINUX_DEFAULT="nomodeset" (i'ts okay if it also has consoleblank=0 at the end."
# GRUB_CMDLINE_LINUX_DEFAULT="nomodeset consoleblank=0"

3) Update and Reload grub.
3a. sudo update-grub
3b. For older Ubuntu try "sudo grub-mkconfig -o /boot/grub/grub.cfg"

4) Add user root (or whoever is the user running the Plex service) to the video group:
4a. sudo usermod -a -G video root

5) Reboot the server

6) Try ls -la /dev/dri now it should find the folder and list drivers

7) chmod -R 777 /dev/dri to change permissions (critical step for use in Docker!

8) I recomend installing and running vainfo and ensure it gives you a positive readout on your driver
8a. sudo apt update
8b. sudo apt install vainfo
8c. vainfo
- You want a line similar to "vainfo: Driver version: Intel i965 driver for Intel(R) Haswell Server - 1.7.0" somewhere in the 18-20 lines it puts out.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Getting it working inside Docker.
It's a relatively small change to the plex.yml - you just have to add the two following lines to the default_volume portion:
- "/dev/dri/card0:/dev/dri/card0"
- "/dev/dri/renderD128:/dev/dri/renderD128"
(If you want to test it, you can run pgfork and use my version under Github username timekills and branch HWtranscode. You can always go back to the standard plexguide version if it doesn't work or you just want to.)

So the plex.yml should look like:

Code:
- name: "Set Default Volume - {{pgrole}}"
  set_fact:
    default_volumes:
      - "/tmp:/tmp"
      - "/opt/appdata/plex/database:/config"
      - "/opt/transcodes:/transcode"
      - "/dev/shm:/ram_transcode"
      - "/dev/dri/card0:/dev/dri/card0"
      - "/dev/dri/renderD128:/dev/dri/renderD128"
      - "/mnt/plexdrive:/plexdrive"
      - "/mnt/encrypt:/encrypt"
      - "/mnt/unionfs:/unionfs"
      - "/:/yourcomputer"
      - "/mnt/gdrive:/gdrive"
      - "/mnt/tdrive:/tdrive"
      - "/etc/localtime:/etc/localtime:ro"
You'll need to reinstall Plex through the plexguide menu. It won't lose any of your settings, and you don't need to reacquire the server. it's pretty painless.

Finally, once you've installed the modified version of Plex, and the Plex Docker container is running, you'll need to run the following commands from the HOST (to make it easier for you):
docker exec plex apt-get -y update
docker exec plex apt-get -y install i965-va-driver vainfo
docker restart plex

That updates the driver now that it can get to the files outside the container.

My Hetzner server CPU is an Intel Xeon E3-1246V3 so it can do x264 HW transcode, but not x265 (as far as my research can tell.) So no dice on the 4K in x265 video. But for x264...

Before the update:

View attachment 2170

After the update:

View attachment 2171

Notice the (hw) after the video transcoding. Hardware transcode!

---- Automatically Merged Double Post ----

By the way, the following command should give a succinct info read on your iGPU:

GPU=$(lspci | grep VGA | cut -d ":" -f3);RAM=$(cardid=$(lspci | grep VGA |cut -d " " -f1);lspci -v -s $cardid | grep " prefetchable"| cut -d "=" -f2);echo $GPU $RAM

For example, on the dedicated server I use, the output is:
Intel Corporation Xeon E3-1200 v3 Processor Integrated Graphics Controller (rev 06) 256M]

On the VPS I use the output is:
Cirrus Logic GD 5446 32M]

(Yeah...the emulated Cirrus Logic ain't going to work.)

Credits

PlexGuide Wiki Article on enabling hardware driver install for Hetzner servers: https://plexguide.com/wikis/plex-hw/: @The Creator and @WildWayz

Original Article
Desimaniac: https://github.com/desimaniac/docs/blob/master/enable_igpu_on_hetzner.md
Thanks for the guide. I just setup my new ex61-nvme server and used this guide, it worked like a charm.
 

Sn0wed

Blitz 1st Class
Staff
50
8
You can do a quick check to see if the drivers are already installed by "ls -la /dev/dri"; you should see something for "card0" and "renderD128" if they are.
When I ran "ls -la/dev/dri" I got
total 0
drwxr-xr-x 3 root root 100 Dec 1 12:55 .
drwxr-xr-x 20 root root 4600 Dec 1 12:55 ..
drwxr-xr-x 2 root root 80 Dec 1 12:55 by-path
crw-rw----+ 1 root video 226, 0 Dec 1 12:55 card0
crw-rw----+ 1 root video 226, 128 Dec 1 12:55 renderD128

I can't tell if I have them or not? Any advice?
 

timekills

Blitz Samurai
Original poster
Staff
Donor
397
167
Yes, that's for iGPU (Intel, specifically.) Not i9 (only); i965 is the driver set for any Intel iGPU.
I don't have any servers with dedicated GPUs so don't know the requirements to get their drivers working but it should be fairly easy to find Nvidia driver install instructions.
 

Sn0wed

Blitz 1st Class
Staff
50
8
Yes, that's for iGPU (Intel, specifically.) Not i9 (only); i965 is the driver set for any Intel iGPU.
I don't have any servers with dedicated GPUs so don't know the requirements to get their drivers working but it should be fairly easy to find Nvidia driver install instructions.
Ok, thanks for the clarification. I have an i7-965 in my server which lacks an iGPU, so could I skip that step if the drivers have been already installed?
 

timekills

Blitz Samurai
Original poster
Staff
Donor
397
167
That step is to install the iGPU drivers in the docker container.
If you already have the drivers installed INSIDE the container, then you don't need to do that step.

If you have a dedicated GPU or an CPU with a different integrated GPU than the Intel from about the 2 series up, then you should install the drivers specific to your system.
 

bubbadk

Blitz Samurai
Staff
350
76
In that case no it hasn't worked as that's now transcoding, did you restart the server after the changes? I messed mine up the first time and wasn't brave enough to try again :)
Yes i did. I followed everything on that first post. And it did find the hardware. hmm.. i'll leave it for now :)
 

bubbadk

Blitz Samurai
Staff
350
76
[email protected] /opt/plexguide/containers # sudo lspci -v -s $(lspci | grep VGA | cut -d" " -f 1)
00:02.0 VGA compatible controller: Intel Corporation HD Graphics 630 (rev 04) (prog-if 00 [VGA controller])
Subsystem: Fujitsu Technology Solutions HD Graphics 630
Flags: bus master, fast devsel, latency 0, IRQ 125
Memory at ee000000 (64-bit, non-prefetchable) [size=16M]
Memory at d0000000 (64-bit, prefetchable) [size=256M]
I/O ports at f000
[virtual] Expansion ROM at 000c0000 [disabled] [size=128K]
Capabilities: [40] Vendor Specific Information: Len=0c <?>
Capabilities: [70] Express Root Complex Integrated Endpoint, MSI 00
Capabilities: [ac] MSI: Enable+ Count=1/1 Maskable- 64bit-
Capabilities: [d0] Power Management version 2
Capabilities: [100] Process Address Space ID (PASID)
Capabilities: [200] Address Translation Service (ATS)
Capabilities: [300] Page Request Interface (PRI)
Kernel driver in use: i915
Kernel modules: i915
 
Assists Greatly with Development Costs

Create an account or login to comment

You must be a member in order to leave a comment

Create account

Create an account on our community. It's easy!

Log in

Already have an account? Log in here.


Development Donations

 

Trending