I currently run Plex in a CentOS 7 VM (on top of vSphere 6.7) with two 2vCPUs and 2GB of vRAM.
When I needed to transcode video to sync it to a mobile device for a trip the process takes a while and consumes a lot of CPU on the VM. I could just add more vCPUs to the VM but I have a limit on how much CPU I have to toss around and there are more efficient ways to transcode video.
I bought my Dell T340 specifically with a Xeon E-2176G CPU in it so I could take advantage of the on-board GPU to handle my transcoding work. After a bunch of back and forth with VMware, Dell and Intel it turns out that Dell did not build the T340 in a way that it can actually use the on-board GPU on my CPU. Why they offer it as a choice, I don’t know but here we are.
My next option was to purchase a video card to do the work. I did some research and came up with the Quadro P620 (specifically the PYN version) being the most affordable with the features I wanted, specifically NVENC. Added bonus, it supports HEVC (H.265) which should future-proof me for a while and allow me to eventually take advantage of this card for transcoding my Blurays to H.265, but that’s another post.
The card arrived, I installed it, enabled it for passthruough in vSphere, attached it to my Plex VM and booted it up.
I downloaded the latest nVidia driver to my VM and ran the installer (as root):
[[email protected] ~]# chmod a+x NVIDIA-Linux-x86_64-430.50.run
[[email protected] ~]# ./NVIDIA-Linux-x86_64-430.50.run
The installation was straight forward, it in fact took care of everything I needed. It automatically blacklisted the default video device for me, asked me to reboot and re-run the installer, which I did and everything almost worked.
After the drive was successfully installed I ran the nvidia tool provided with the drivers to verify things and was greeted with:
[[email protected] ~]# nvidia-smi
Unable to determine the device handle for GPU 0000:03:00.0: Unknown Error
Fortunately this issue is well documented on the internet and the quick fix was to shut down the VM and make a tweak to it’s configuration. Since I have vCenter I used the GUI to solve this problem instead of downloading the VMX file, editing it and re-uploading the VMX file for the VM:
- Login to vCenter
- Right click and choose ‘Edit Settings’ on the VM
- Go to ‘VM Options’ and expand ‘Advanced’
- Click ‘Edit Configuration’
- Click ‘Add Configuration Params’
- Enter the following without quotes:
Name: “hypervisor.cpuid.v0”
Value: “FALSE”
- Click ‘Ok’
- Click ‘Ok’
- Boot up the VM
Once the VM came back up I got the output I was expecting from nvidia-smi
[[email protected] ~]# nvidia-smi
Thu Oct 24 18:36:20 2019
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 430.50 Driver Version: 430.50 CUDA Version: 10.1 |
|-------------------------------+----------------------+----------------------+
| GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |
|===============================+======================+======================|
| 0 Quadro P620 Off | 00000000:13:00.0 Off | N/A |
| 40% 54C P0 N/A / N/A | 10MiB / 2000MiB | 0% Default |
+-------------------------------+----------------------+----------------------+
+-----------------------------------------------------------------------------+
| Processes: GPU Memory |
| GPU PID Type Process name Usage |
|=============================================================================|
| No running processes found |
+-----------------------------------------------------------------------------+
The last thing to do before testing was to make sure Plex was configured to use hardware transcoding:
- Login to your Plex’s WebUI
- Under ‘Settings’ click ‘Transcoder’
- Checkmark ‘Use hardware acceleration when avalible’
- Click ‘Save Changes’
I then gave things a quick test by trying to sync a TV show to my iPhone and then re-ran nvidia-smi:
[[email protected] ~]# nvidia-smi
Thu Oct 24 18:38:59 2019
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 430.50 Driver Version: 430.50 CUDA Version: 10.1 |
|-------------------------------+----------------------+----------------------+
| GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |
|===============================+======================+======================|
| 0 Quadro P620 Off | 00000000:13:00.0 Off | N/A |
| 41% 57C P0 N/A / N/A | 177MiB / 2000MiB | 20% Default |
+-------------------------------+----------------------+----------------------+
+-----------------------------------------------------------------------------+
| Processes: GPU Memory |
| GPU PID Type Process name Usage |
|=============================================================================|
| 0 22510 C /usr/lib/plexmediaserver/Plex Transcoder 167MiB |
+-----------------------------------------------------------------------------+
Bingo, that was it. Now. How much faster was the Quadro P620 over my Xeon E-2176G, roughly 4.5x faster.
-
-
CPU transcoding
-
-
GPU (NVENC) transcoding
My Plex transcoding settings are:
- Transcoder quality: Prefer higher quality encoding
- Background transcoding x264 preset: Medium
- Maximum simultaneous video transcode: 4
But wait you might say, why set “Maximum simultaneous video transcode” to “4”? A Quadro P620 can only do 2?
This is why, only took a few seconds as root:
# git clone https://github.com/keylase/nvidia-patch.git
# cd nvidia-patch/
# bash patch.sh