Hardware transcoding not working on Ubuntu 20.04.2

Server Version#: 1.22.3.4392
Player Version#: Web, i.e. via browser

I have plex installed on Ubuntu 20.04.2:

$ uname -a
Linux plex 5.4.0-72-generic #80-Ubuntu SMP Mon Apr 12 17:35:00 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 20.04.2 LTS
Release:        20.04
Codename:       focal

The server is a VM running on ESXi 7.0.0, PCI passthrough enabled for the VGA card:

$ lspci | fgrep VGA
0b:00.0 VGA compatible controller: NVIDIA Corporation GM107 [GeForce GTX 750 Ti] (rev a2)

According to the Intel website for my CPU, the CPU supports Quick Link:

$ lscpu | fgrep "Model name:"
Model name:                      Intel(R) Core(TM) i7-4790 CPU @ 3.60GHz

And I have an active Plex Pass subscription.

I think I have the correct NVIDIA drivers installed:

$ modinfo /usr/lib/modules/5.4.0-72-generic/kernel/drivers/video/nvidia.ko | fgrep ver
filename:       /usr/lib/modules/5.4.0-72-generic/kernel/drivers/video/nvidia.ko
version:        460.73.01
$ modinfo /usr/lib/modules/5.4.0-72-generic/kernel/drivers/video/nvidia-drm.ko | fgrep ver
filename:       /usr/lib/modules/5.4.0-72-generic/kernel/drivers/video/nvidia-drm.ko
version:        460.73.01 

I only have one device listed in /dev/dri:

$ ls -l /dev/dri/
total 0
drwxr-xr-x 2 root root         80 May  2 07:15 by-path
crw-rw---- 1 root render 226,   0 May  2 07:15 card0
crw-rw---- 1 root render 226, 128 May  2 07:15 renderD128

However, transcoding happens without hardware.

Non-verbose logs attached, but they key bit seems to be:

$ fgrep -a -e TPU -e hardware Plex\ Media\ Server.log | fgrep "May 02, 2021 09:"
May 02, 2021 09:37:42.309 [0x7f93d1ffb700] DEBUG - [Transcode] Codecs: hardware transcoding: testing API vaapi
May 02, 2021 09:37:42.309 [0x7f93d1ffb700] DEBUG - [Transcode] Codecs: hardware transcoding: opening hw device failed - probably not supported by this system, error: Input/output error
May 02, 2021 09:37:42.309 [0x7f93d1ffb700] DEBUG - [Transcode] Codecs: hardware transcoding: testing API nvenc
May 02, 2021 09:37:42.594 [0x7f93d1ffb700] DEBUG - [Transcode] Codecs: hardware transcoding: opening hw device failed - probably not supported by this system, error: Unknown error occurred
May 02, 2021 09:37:42.594 [0x7f93d1ffb700] DEBUG - [Transcode] Codecs: hardware transcoding: testing API vaapi
May 02, 2021 09:37:42.594 [0x7f93d1ffb700] DEBUG - [Transcode] Codecs: hardware transcoding: opening hw device failed - probably not supported by this system, error: Input/output error
May 02, 2021 09:37:42.594 [0x7f93d1ffb700] DEBUG - [Transcode] Codecs: hardware transcoding: testing API nvdec
May 02, 2021 09:37:42.849 [0x7f93d1ffb700] DEBUG - [Transcode] Codecs: hardware transcoding: opening hw device failed - probably not supported by this system, error: Unknown error occurred
May 02, 2021 09:37:42.850 [0x7f93d1ffb700] DEBUG - [Transcode] Codecs: hardware transcoding: testing API nvenc
May 02, 2021 09:37:43.104 [0x7f93d1ffb700] DEBUG - [Transcode] Codecs: hardware transcoding: opening hw device failed - probably not supported by this system, error: Unknown error occurred
May 02, 2021 09:37:43.105 [0x7f93d1ffb700] DEBUG - [Transcode] Codecs: hardware transcoding: testing API vaapi
May 02, 2021 09:37:43.105 [0x7f93d1ffb700] DEBUG - [Transcode] Codecs: hardware transcoding: opening hw device failed - probably not supported by this system, error: Input/output error
May 02, 2021 09:37:43.105 [0x7f93d1ffb700] DEBUG - [Transcode] Codecs: hardware transcoding: testing API nvdec
May 02, 2021 09:37:43.358 [0x7f93d1ffb700] DEBUG - [Transcode] Codecs: hardware transcoding: opening hw device failed - probably not supported by this system, error: Unknown error occurred
May 02, 2021 09:37:43.612 [0x7f9411ffb700] DEBUG - [Transcode] TPU: hardware transcoding: enabled, but no hardware decode accelerator found
May 02, 2021 09:37:43.612 [0x7f9411ffb700] DEBUG - [Transcode] TPU: hardware transcoding: final decoder: , final encoder:

I’m obviously missing something to, but can’t figure out what.

Any pointers greatly appreciated!

Thanks!

Plex Media Server Logs_2021-05-02_09-38-51.zip (1.1 MB)

Bit more info… I expected these to show something…

$ sudo vainfo
error: XDG_RUNTIME_DIR not set in the environment.
error: can't connect to X server!
libva info: VA-API version 1.7.0
libva error: vaGetDriverNameByIndex() failed with unknown libva error, driver_name = (null)
vaInitialize failed with error code -1 (unknown libva error),exit

$ sudo vdpauinfo
vdpauinfo: cannot connect to X server

I don’t have X - Ubuntu server edition, CLI only.

And a bit more info…

$ sudo lspci -v -s $(lspci | grep VGA | cut -d" " -f 1)
0b:00.0 VGA compatible controller: NVIDIA Corporation GM107 [GeForce GTX 750 Ti] (rev a2) (prog-if 00 [VGA controller])
        DeviceName: pciPassthru0
        Subsystem: ZOTAC International (MCO) Ltd. GM107 [GeForce GTX 750 Ti]
        Physical Slot: 192
        Flags: bus master, fast devsel, latency 64, IRQ 19
        Memory at fb000000 (32-bit, non-prefetchable) [size=16M]
        Memory at c0000000 (64-bit, prefetchable) [size=256M]
        Memory at d0000000 (64-bit, prefetchable) [size=32M]
        I/O ports at 3000 [size=128]
        Capabilities: [60] Power Management version 3
        Capabilities: [68] MSI: Enable- Count=1/1 Maskable- 64bit+
        Capabilities: [78] Express Endpoint, MSI 00
        Capabilities: [100] Virtual Channel
        Capabilities: [258] L1 PM Substates
        Capabilities: [128] Power Budgeting <?>
        Capabilities: [600] Vendor Specific Information: ID=0001 Rev=1 Len=024 <?>
        Capabilities: [900] Secondary PCI Express
        Kernel driver in use: nvidia
        Kernel modules: nvidiafb, nouveau, nvidia_drm, nvidia

Try this

Thanks @Morphy. I think the passthru is working ok because the nVidia card is shown correctly by lspci. Unless I’m missing something?

Just a wild shot, try upgrade the kernel .

sudo apt install --install-recommends linux-generic-hwe-20.04

Dont think that plex supports vm (official) by the way :wink:

Yeah, I get the impression Plex in a VM isn’t officially supported, but there’s plenty of examples of it working - and my situation is a pretty straightforward one.

It feels like the card is being seen by the OS, but there isn’t a decoder/encoder between Plex and the card, but can’t figure out what’s missing.

Check the nvidia drivers protocol version.
Drivers must be 9.0 and higher.

Using QNAP as a base: libnvidia-encode.so.440.82 is protocol 10.2 and does work

Check /dev/dri.
If there are multiple devices listed, make certain to update HardwareDevicePath="/dev/dri/renderDxxx" appropriately.

May or may not be related but said I’d mention it in case its a factor.

I noticed the kernel you are running is 5.4.x. My own ubuntu 20.04.2 is running 5.8.0-50-generic. Maybe those latest nvidia drivers don’t like the 5.4 kernel.

Thanks @anon5074910 and @Morphy for the kernel suggestion, but the upgrade doesn’t seem to have made a difference:

$ uname -r
5.8.0-50-generic
$ tail -f Plex\ Media\ Server.log | fgrep -a -e hardware -e TPU
May 03, 2021 06:31:28.673 [0x7f2322ffd700] DEBUG - [Transcode] Codecs: hardware transcoding: testing API vaapi
May 03, 2021 06:31:28.673 [0x7f2322ffd700] DEBUG - [Transcode] Codecs: hardware transcoding: opening hw device failed - probably not supported by this system, error: Generic error in an external library
May 03, 2021 06:31:28.674 [0x7f2322ffd700] DEBUG - [Transcode] Codecs: hardware transcoding: testing API nvenc
May 03, 2021 06:31:28.782 [0x7f2322ffd700] DEBUG - [Transcode] Codecs: hardware transcoding: opening hw device failed - probably not supported by this system, error: Unknown error occurred
May 03, 2021 06:31:28.782 [0x7f2322ffd700] DEBUG - [Transcode] Codecs: hardware transcoding: testing API vaapi
May 03, 2021 06:31:28.782 [0x7f2322ffd700] DEBUG - [Transcode] Codecs: hardware transcoding: opening hw device failed - probably not supported by this system, error: Generic error in an external library
May 03, 2021 06:31:28.782 [0x7f2322ffd700] DEBUG - [Transcode] Codecs: hardware transcoding: testing API nvdec
May 03, 2021 06:31:28.876 [0x7f2322ffd700] DEBUG - [Transcode] Codecs: hardware transcoding: opening hw device failed - probably not supported by this system, error: Unknown error occurred
May 03, 2021 06:31:28.876 [0x7f2322ffd700] DEBUG - [Transcode] Codecs: hardware transcoding: testing API nvenc
May 03, 2021 06:31:28.971 [0x7f2322ffd700] DEBUG - [Transcode] Codecs: hardware transcoding: opening hw device failed - probably not supported by this system, error: Unknown error occurred
May 03, 2021 06:31:28.972 [0x7f2322ffd700] DEBUG - [Transcode] Codecs: hardware transcoding: testing API vaapi
May 03, 2021 06:31:28.972 [0x7f2322ffd700] DEBUG - [Transcode] Codecs: hardware transcoding: opening hw device failed - probably not supported by this system, error: Generic error in an external library
May 03, 2021 06:31:28.972 [0x7f2322ffd700] DEBUG - [Transcode] Codecs: hardware transcoding: testing API nvdec
May 03, 2021 06:31:29.071 [0x7f2322ffd700] DEBUG - [Transcode] Codecs: hardware transcoding: opening hw device failed - probably not supported by this system, error: Unknown error occurred
May 03, 2021 06:31:29.628 [0x7f23117fa700] DEBUG - [Transcode] TPU: hardware transcoding: enabled, but no hardware decode accelerator found
May 03, 2021 06:31:29.629 [0x7f23117fa700] DEBUG - [Transcode] TPU: hardware transcoding: final decoder: , final encoder: 
May 03, 2021 06:31:30.641 [0x7f2322ffd700] DEBUG - [Transcode/5x0kq1yzwz94bupx8xf4nbx3] TPU: hardware transcoding: enabled, but no hardware decode accelerator found
May 03, 2021 06:31:30.641 [0x7f2322ffd700] DEBUG - [Transcode/5x0kq1yzwz94bupx8xf4nbx3] TPU: hardware transcoding: final decoder: , final encoder: 
^C

Although oddly, after the upgrade, /dev/dri doesn’t seem to exist…?

$ ls -l /dev/d*
lrwxrwxrwx 1 root root   3 May  3 06:26 /dev/dvd -> sr0

/dev/disk:
total 0
drwxr-xr-x 2 root root  60 May  3 06:26 by-id
drwxr-xr-x 2 root root 100 May  3 06:26 by-partuuid
drwxr-xr-x 2 root root 160 May  3 06:26 by-path
drwxr-xr-x 2 root root 100 May  3 06:26 by-uuid

/dev/dma_heap:
total 0
crw------- 1 root root 249, 0 May  3 06:26 system

But the card is still shown by lspci:

$ lspci | fgrep VGA
0b:00.0 VGA compatible controller: NVIDIA Corporation GM107 [GeForce GTX 750 Ti] (rev a2)

It was present before the upgrade - see OP.

@ChuckPa , how can I find out the protocol version?

$ sudo find / -type f -name 'libnvidia-en*' -print0 | xargs -0 ls -l
-rwxr-xr-x 1 root root 124048 May  1 14:52 /usr/lib32/libnvidia-encode.so.460.73.01
-rwxr-xr-x 1 root root 112664 May  1 14:52 /usr/lib/x86_64-linux-gnu/libnvidia-encode.so.460.73.01

Thanks very much everyone!

Hmm, also, I just checked:

/var/lib/plexmediaserver/Library/Application Support/Plex Media Server/Preferences.xml

and there is no entry at all for:

HardwareDevicePath=

Everything else in there looks sane.

And in case it matters:

$ sudo groups plex
plex : plex video render

I noticed that having removed the default ESXi SVGA device I couldn’t see anything at the ESXi console. I added the ESXi SVGA device and then I have this:

$ lspci | fgrep VGA
00:0f.0 VGA compatible controller: VMware SVGA II Adapter
0b:00.0 VGA compatible controller: NVIDIA Corporation GM107 [GeForce GTX 750 Ti] (rev a2)
$ ls -l /dev/dri/
total 0
drwxr-xr-x  2 root root         80 May  3 15:11 by-path
crw-rw----+ 1 root render 226,   0 May  3 15:11 card0
crw-rw----+ 1 root render 226, 128 May  3 15:11 renderD128
$ ls -l /dev/dri/by-path/
total 0
lrwxrwxrwx 1 root root  8 May  3 15:11 pci-0000:00:0f.0-card -> ../card0
lrwxrwxrwx 1 root root 13 May  3 15:11 pci-0000:00:0f.0-render -> ../renderD128

So, this seems like even though the NVIDIA card is listed by lspci, it’s not showing up in /dev/dri/.

(I’m assuming /dev/dri/by-path/pci-0000:00:0f.0-card == 00:0f.0 VGA compatible controller: VMware SVGA II Adapter)

Hmm, so, given the OS can “see” the card (lspci), why isn’t it shown in /dev/dri?

Could be an OS thing? How did you install the nvidia drivers?

I typically use the ones from sudo add-apt-repository ppa:graphics-drivers/ppa but my setup is different as its physical and not virtual but maybe worth a try reinstalling nvidia.

Yeah, agreed @anon5074910: feels like it’s a drivers thing. I installed the drivers by downloading the installer from the nvidia website: NVIDIA-Linux-x86_64-460.73.01.run.

Guess I could try and remove and install from the PPA.

The tester in me says give it a go. At least would rule it out as a factor.

I’ve also had many oddities running official nvidia drivers from their website on various flavours of Linux that my default now is too use ones from the Linux repros instead.

So, because I had the official NVIDIA ones from the website handy I thought I’d try a reinstall.

This resulted in the card showing in /dev/dri/:

$ ls -lR /dev/dri
/dev/dri:
total 0
drwxr-xr-x  2 root root        120 May  3 16:06 by-path
crw-rw----+ 1 root render 226,   0 May  3 16:06 card0
crw-rw----+ 1 root render 226,   1 May  3 16:06 card1
crw-rw----+ 1 root render 226, 128 May  3 16:06 renderD128
crw-rw----+ 1 root render 226, 129 May  3 16:06 renderD129

/dev/dri/by-path:
total 0
lrwxrwxrwx 1 root root  8 May  3 16:06 pci-0000:00:0f.0-card -> ../card0
lrwxrwxrwx 1 root root 13 May  3 16:06 pci-0000:00:0f.0-render -> ../renderD128
lrwxrwxrwx 1 root root  8 May  3 16:06 pci-0000:0b:00.0-card -> ../card1
lrwxrwxrwx 1 root root 13 May  3 16:06 pci-0000:0b:00.0-render -> ../renderD129

which is progress.

I then stopped the plexmediaserver service, updated my Preferences.xml:

$ cat /var/lib/plexmediaserver/Library/Application\ Support/Plex\ Media\ Server/Preferences.xml 
<?xml version="1.0" encoding="utf-8"?>
<Preferences ...SNIPPED... HardwareAcceleratedCodecs="1" HardwareDevicePath="/dev/dri/renderD129" />

and restarted the service.

But playing a video with transcoding, I still get exactly the same errors I had in the OP.

Once I figure out how to uninstall the official drivers I’ll try the PPA ones.

FYI… 1.23.0.4438 crash with HEVC files - #64 by ChuckPa

Wonder if this was your problem as well?

Thanks @anon5074910 - I don’t think that’s the same problem I’m having. I notice @ChuckPa is in this thread, so hopefully they’ll correct me otherwise.

With respect to using the NVIDIA drivers from the distro (not the PPA yet) rather than from NVIDIA’s website, here’s what I did:

Uninstalled with:

sudo ./NVIDIA-Linux-x86_64-460.73.01.run --uninstall

Uninstall appeared to happen successfully.

Rebooted the VM.

Then:

$ ubuntu-drivers devices
WARNING:root:_pkg_get_support nvidia-driver-390: package has invalid Support Legacyheader, cannot determine support level
== /sys/devices/pci0000:00/0000:00:16.0/0000:0b:00.0 ==
modalias : pci:v000010DEd00001380sv000019DAsd0000288Abc03sc00i00
vendor   : NVIDIA Corporation
model    : GM107 [GeForce GTX 750 Ti]
driver   : nvidia-driver-460 - distro non-free recommended
driver   : nvidia-driver-460-server - distro non-free
driver   : nvidia-driver-450 - distro non-free
driver   : nvidia-driver-390 - distro non-free
driver   : nvidia-340 - distro non-free
driver   : nvidia-driver-450-server - distro non-free
driver   : nvidia-driver-418-server - distro non-free
driver   : xserver-xorg-video-nouveau - distro free builtin

== /sys/devices/pci0000:00/0000:00:0f.0 ==
modalias : pci:v000015ADd00000405sv000015ADsd00000405bc03sc00i00
vendor   : VMware
model    : SVGA II Adapter
manual_install: True
driver   : open-vm-tools-desktop - distro free

Then:

$ sudo apt install nvidia-driver-460 --no-install-recommends
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
  dctrl-tools dkms libegl-mesa0 libegl1 libepoxy0 libfontenc1 libgbm1 libgl1 libgl1-mesa-dri libglapi-mesa libglvnd0 libglx-mesa0 libglx0 libice6 libnvidia-cfg1-460 libnvidia-common-460 libnvidia-compute-460 libnvidia-decode-460
  libnvidia-encode-460 libnvidia-extra-460 libnvidia-fbc1-460 libnvidia-gl-460 libnvidia-ifr1-460 libpixman-1-0 libsensors-config libsensors5 libsm6 libvulkan1 libwayland-server0 libxaw7 libxcb-glx0 libxdamage1 libxfont2 libxkbfile1
  libxmu6 libxpm4 libxt6 libxxf86vm1 nvidia-compute-utils-460 nvidia-dkms-460 nvidia-kernel-common-460 nvidia-kernel-source-460 nvidia-utils-460 x11-common x11-xkb-utils xserver-common xserver-xorg-core xserver-xorg-video-nvidia-460
Suggested packages:
  debtags menu lm-sensors xfonts-100dpi | xfonts-75dpi xfonts-scalable
Recommended packages:
  mesa-vulkan-drivers | vulkan-icd nvidia-settings nvidia-prime libnvidia-compute-460:i386 libnvidia-decode-460:i386 libnvidia-encode-460:i386 libnvidia-ifr1-460:i386 libnvidia-fbc1-460:i386 libnvidia-gl-460:i386 xfonts-base
The following packages will be REMOVED:
  libnvidia-compute-460-server nvidia-utils-460-server
The following NEW packages will be installed:
  dctrl-tools dkms libegl-mesa0 libegl1 libepoxy0 libfontenc1 libgbm1 libgl1 libgl1-mesa-dri libglapi-mesa libglvnd0 libglx-mesa0 libglx0 libice6 libnvidia-cfg1-460 libnvidia-common-460 libnvidia-compute-460 libnvidia-decode-460
  libnvidia-encode-460 libnvidia-extra-460 libnvidia-fbc1-460 libnvidia-gl-460 libnvidia-ifr1-460 libpixman-1-0 libsensors-config libsensors5 libsm6 libvulkan1 libwayland-server0 libxaw7 libxcb-glx0 libxdamage1 libxfont2 libxkbfile1
  libxmu6 libxpm4 libxt6 libxxf86vm1 nvidia-compute-utils-460 nvidia-dkms-460 nvidia-driver-460 nvidia-kernel-common-460 nvidia-kernel-source-460 nvidia-utils-460 x11-common x11-xkb-utils xserver-common xserver-xorg-core
  xserver-xorg-video-nvidia-460
0 upgraded, 49 newly installed, 2 to remove and 0 not upgraded.
Need to get 145 MB of archives.
After this operation, 653 MB of additional disk space will be used.
Do you want to continue? [Y/n]

All seemed to go OK.

Rebooted the VM.

Then tried to watch something with encoding:

$ tail -f /var/lib/plexmediaserver/Library/Application\ Support/Plex\ Media\ Server/Logs/Plex\ Media\ Server.log | fgrep -a -i -e TPU -e hardware
May 04, 2021 19:09:17.050 [0x7fe0ecff9700] DEBUG - [Transcode] Codecs: hardware transcoding: testing API vaapi
May 04, 2021 19:09:17.051 [0x7fe0ecff9700] DEBUG - [Transcode] Codecs: hardware transcoding: opening hw device failed - probably not supported by this system, error: Input/output error
May 04, 2021 19:09:17.051 [0x7fe0ecff9700] DEBUG - [Transcode] Codecs: hardware transcoding: testing API nvenc
May 04, 2021 19:09:17.316 [0x7fe0ecff9700] DEBUG - [Transcode] Codecs: hardware transcoding: opening hw device failed - probably not supported by this system, error: Unknown error occurred
May 04, 2021 19:09:17.316 [0x7fe0ecff9700] DEBUG - [Transcode] Codecs: hardware transcoding: testing API nvenc
May 04, 2021 19:09:17.573 [0x7fe0ecff9700] DEBUG - [Transcode] Codecs: hardware transcoding: opening hw device failed - probably not supported by this system, error: Unknown error occurred
May 04, 2021 19:09:26.251 [0x7fe0ee7fc700] DEBUG - [Transcode] Codecs: hardware transcoding: testing API nvenc
May 04, 2021 19:09:26.507 [0x7fe0ee7fc700] DEBUG - [Transcode] Codecs: hardware transcoding: opening hw device failed - probably not supported by this system, error: Unknown error occurred
May 04, 2021 19:09:26.508 [0x7fe0ee7fc700] DEBUG - [Transcode] Codecs: hardware transcoding: testing API nvenc
May 04, 2021 19:09:26.766 [0x7fe0ee7fc700] DEBUG - [Transcode] Codecs: hardware transcoding: opening hw device failed - probably not supported by this system, error: Unknown error occurred
May 04, 2021 19:09:48.941 [0x7fe0ee7fc700] DEBUG - [Transcode] TPU: hardware transcoding: enabled, but no hardware decode accelerator found
May 04, 2021 19:09:48.941 [0x7fe0ee7fc700] DEBUG - [Transcode] TPU: hardware transcoding: final decoder: , final encoder:
May 04, 2021 19:09:49.514 [0x7fe0ee7fc700] DEBUG - [Transcode/8gt1adn0f3uenrl2paocyk1q] TPU: hardware transcoding: enabled, but no hardware decode accelerator found
May 04, 2021 19:09:49.514 [0x7fe0ee7fc700] DEBUG - [Transcode/8gt1adn0f3uenrl2paocyk1q] TPU: hardware transcoding: final decoder: , final encoder:

Interestingly, the 9 second delay from 19:09:17 to 19:09:26 is because PMS WebUI showed an error trying to play the video. I clicked Retry and then it carried on.

Hmm… might that be a crash as described in the link @anon5074910 shared?

I guess as the drivers from the distro didn’t make any difference, the PPA is next.

phew!

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.