Hardware Transcoding on Linux not working AMDGPU v1.32.5.7210

Server Version#: Plex Media Server v1.32.5.7210-77f7f99fa - build: linux-x86_64 redhat - GMT 02:00
Player Version#: Plex Web Version 4.108.0
Linux version: 6.3.5-2-MANJARO

I’m glad that the Plex team has been working on amdgpu support on Linux, I’ve been keeping an eye on the changelogs and got excited when reading the latest additions.

I went straight to testing! While the GPU is correctly recognized and selectable in the GUI, unfortunately the GPU is not utilised for transcoding and it defaults to the CPU.

Specifically tested h264 SDR & HEVC SDR files, both bt709.

Below the output of several commands I thought would provide useful info.

mediainfo - HEVC SDR
General
Complete name                            : g201_TH_804_A001_8_SDR_20191031_SDR_4K_HEVC.mov
Format                                   : MPEG-4
Format profile                           : QuickTime
Codec ID                                 : qt   0000.00 (qt  )
File size                                : 120 MiB
Duration                                 : 1 min 24 s
Overall bit rate                         : 11.9 Mb/s
Frame rate                               : 29.970 FPS
Encoded date                             : 2019-11-05 19:52:06 UTC
Tagged date                              : 2019-11-05 19:52:06 UTC
Writing library                          : Apple QuickTime

Video
ID                                       : 1
Format                                   : HEVC
Format/Info                              : High Efficiency Video Coding
Format profile                           : Main 10@L5@High
Codec ID                                 : hvc1
Codec ID/Info                            : High Efficiency Video Coding
Duration                                 : 1 min 24 s
Bit rate                                 : 11.9 Mb/s
Width                                    : 3 840 pixels
Height                                   : 2 160 pixels
Display aspect ratio                     : 16:9
Frame rate mode                          : Constant
Frame rate                               : 29.970 (30000/1001) FPS
Color space                              : YUV
Chroma subsampling                       : 4:2:0
Bit depth                                : 10 bits
Bits/(Pixel*Frame)                       : 0.048
Stream size                              : 120 MiB (100%)
Title                                    : Core Media Video
Encoded date                             : 2019-11-05 19:52:06 UTC
Tagged date                              : 2019-11-05 19:52:06 UTC
Color range                              : Limited
Color primaries                          : BT.709
Transfer characteristics                 : BT.709
Matrix coefficients                      : BT.709
Codec configuration box                  : hvcC
mediainfo - h264 SDR
General
Unique ID                                : 241431630945555670297795874629822138060 (0xB5A20A6EFCB54064E00E706C210F46CC)
Complete name                            : This.Place.Rules.2022.mkv
Format                                   : Matroska
Format version                           : Version 4
File size                                : 5.25 GiB
Duration                                 : 1 h 22 min
Overall bit rate                         : 9 154 kb/s
Frame rate                               : 24.000 FPS
Writing application                      : mkvmerge v72.0.0 ('Minuano (Six-eight)') 64-bit
Writing library                          : libebml v1.4.4 + libmatroska v1.7.1

Video
ID                                       : 1
Format                                   : AVC
Format/Info                              : Advanced Video Codec
Format profile                           : High@L4
Format settings                          : CABAC / 4 Ref Frames
Format settings, CABAC                   : Yes
Format settings, Reference frames        : 4 frames
Codec ID                                 : V_MPEG4/ISO/AVC
Duration                                 : 1 h 22 min
Bit rate mode                            : Constant
Bit rate                                 : 8 511 kb/s
Nominal bit rate                         : 10 000 kb/s
Width                                    : 1 920 pixels
Height                                   : 1 080 pixels
Display aspect ratio                     : 16:9
Frame rate mode                          : Constant
Frame rate                               : 24.000 FPS
Color space                              : YUV
Chroma subsampling                       : 4:2:0
Bit depth                                : 8 bits
Scan type                                : Progressive
Bits/(Pixel*Frame)                       : 0.171
Stream size                              : 4.88 GiB (93%)
Default                                  : Yes
Forced                                   : No
Color range                              : Limited
Color primaries                          : BT.709
Transfer characteristics                 : BT.709
Matrix coefficients                      : BT.709

Audio
ID                                       : 2
Format                                   : E-AC-3
Format/Info                              : Enhanced AC-3
Commercial name                          : Dolby Digital Plus
Codec ID                                 : A_EAC3
Duration                                 : 1 h 22 min
Bit rate mode                            : Constant
Bit rate                                 : 640 kb/s
Channel(s)                               : 6 channels
Channel layout                           : L R C LFE Ls Rs
Sampling rate                            : 48.0 kHz
Frame rate                               : 31.250 FPS (1536 SPF)
Compression mode                         : Lossy
Stream size                              : 376 MiB (7%)
Language                                 : English (US)
Service kind                             : Complete Main
Default                                  : Yes
Forced                                   : No

Text #1
ID                                       : 3
Format                                   : UTF-8
Codec ID                                 : S_TEXT/UTF8
Codec ID/Info                            : UTF-8 Plain Text
Duration                                 : 1 h 21 min
Bit rate                                 : 122 b/s
Frame rate                               : 0.401 FPS
Count of elements                        : 1955
Stream size                              : 72.6 KiB (0%)
Language                                 : English (US)
Default                                  : No
Forced                                   : No

Text #2
ID                                       : 4
Format                                   : UTF-8
Codec ID                                 : S_TEXT/UTF8
Codec ID/Info                            : UTF-8 Plain Text
Duration                                 : 1 h 21 min
Bit rate                                 : 127 b/s
Frame rate                               : 0.418 FPS
Count of elements                        : 2041
Stream size                              : 75.9 KiB (0%)
Title                                    : SDH
Language                                 : English (US)
Default                                  : No
Forced                                   : No
preferences.xml
<?xml version="1.0" encoding="utf-8"?>
<Preferences OldestPreviousVersion="1.21.1.3842-b0c7a97d9" MachineIdentifier="removed" ProcessedMachineIdentifier="removed" AnonymousMachineIdentifier="removed" MetricsEpoch="1" AcceptedEULA="1" FriendlyName="removed" PublishServerOnPlexOnlineKey="1" PlexOnlineToken="removed" PlexOnlineUsername="removed" PlexOnlineMail="removed" PlexOnlineHome="1" DlnaEnabled="0" DvrIncrementalEpgLoader="0" CertificateVersion="3" CertificateUUID="removed" LastAutomaticMappedPort="0" PubSubServer="139.162.219.82" PubSubServerRegion="lhr" PubSubServerPing="65" LanguageInCloud="1" sendCrashReports="1" autoEmptyTrash="1" GenerateIntroMarkerBehavior="scheduled" WanPerStreamMaxUploadRate="0" WanTotalMaxUploadRate="30000" HardwareAcceleratedCodecs="1" FSEventLibraryPartialScanEnabled="1" FSEventLibraryUpdatesEnabled="1" CloudSyncNeedsUpdate="0" ScheduledLibraryUpdatesEnabled="0" allowMediaDeletion="0" TranscoderH264BackgroundPreset="ultrafast" TranscoderQuality="3" ManualPortMappingMode="1" ManualPortMappingPort="32400" logDebug="1" HardwareAcceleratedEncoders="1" EnableIPv6="0" secureConnections="1" DisableTLSv1_0="0" WebHooksEnabled="1" ButlerTaskGenerateAutoTags="0" LoudnessAnalysisBehavior="never" OnDeckLimit="10" OnDeckWindow="2" PreferredNetworkInterface="eno1" CinemaTrailersFromBluRay="0" LogVerbose="1" PushNotificationsEnabled="0" MusicAnalysisBehavior="never" TranscoderToneMapping="1" MergedRecentlyAdded="1" GlobalMusicVideoPathMigrated="1" CinemaTrailersFromTheater="0" ButlerEndHour="8" ButlerStartHour="1" ButlerTaskRefreshLibraries="1" TranscoderCanOnlyRemuxVideo="0" TranscodeCountLimit="0" ButlerTaskDeepMediaAnalysis="0" WanPerUserStreamCount="0" ButlerUpdateChannel="8" CinemaTrailersFromLibrary="0" RelayEnabled="0" TreatWanIpAsLocal="1" ButlerTaskReverseGeocode="0" DatabaseCacheSize="256" LibraryVideoPlayedAtBehaviour="1" MarkerSource="cloud" GenerateCreditsMarkerBehavior="asap" GenerateChapterThumbBehavior="never" ScannerLowPriority="1" HardwareDevicePath="1002:744c:148c:2423@0000:03:00.0"/>
uname -a
Linux manjaro 6.3.5-2-MANJARO #1 SMP PREEMPT_DYNAMIC Sun Jun  4 18:26:12 UTC 2023 x86_64 GNU/Linux
lspci | grep VGA
03:00.0 VGA compatible controller: Advanced Micro Devices, Inc. [AMD/ATI] Navi 31 [Radeon RX 7900 XT/7900 XTX] (rev cc)
inxi -G
Graphics:
  Device-1: AMD Navi 31 [Radeon RX 7900 XT/7900 XTX] driver: amdgpu v: kernel
  Display: x11 server: X.Org v: 21.1.8 driver: X: loaded: amdgpu
    unloaded: modesetting dri: radeonsi gpu: amdgpu resolution: 3440x1440~60Hz
  API: OpenGL v: 4.6 Mesa 23.0.2 renderer: AMD Radeon RX 7900 XT (gfx1100
    LLVM 15.0.7 DRM 3.52 6.3.5-2-MANJARO)
tree /usr/lib/plexmediaserver/lib/
/usr/lib/plexmediaserver/lib/
├── dri
│   ├── radeonsi_dri.so
│   └── radeonsi_drv_video.so
├── ld-musl-x86_64.so.1
├── libavcodec.so.59
├── libavfilter.so.8
├── libavformat.so.59
├── libavutil.so.57
├── libboost_atomic.so
├── libboost_chrono.so
├── libboost_date_time.so
├── libboost_filesystem.so
├── libboost_iostreams.so
├── libboost_json.so
├── libboost_locale.so
├── libboost_program_options.so
├── libboost_random.so
├── libboost_regex.so
├── libboost_system.so
├── libboost_thread.so
├── libboost_timer.so
├── libcharset.so.1
├── libcrypto.so.3
├── libc.so
├── libc++.so.2
├── libcurl.so.4
├── libdrm_amdgpu.so.1
├── libdrm_intel.so.1
├── libdrm_radeon.so.1
├── libdrm.so.2
├── libeditline.so.1
├── libfmt.so.8
├── libfreeimage.so
├── libgcompat.so.0
├── libgmock.so
├── libgtest.so
├── libhdhomerun.so
├── libiconv.so.2
├── libicudataplex.so.69
├── libicui18nplex.so.69
├── libicuioplex.so.69
├── libicuucplex.so.69
├── libigdgmm.so.12
├── libminiupnpc.so.17
├── libnghttp2.so
├── libopencv_core.so.405
├── libopencv_dnn.so.405
├── libopencv_imgcodecs.so.405
├── libopencv_imgproc.so.405
├── libpciaccess.so.0
├── libpion.so
├── libpython27.so
├── libsoci_core.so
├── libsoci_sqlite3.so
├── libsqlite3.so
├── libssl.so.3
├── libstdc++.so.6
├── libswresample.so.4
├── libswscale.so.6
├── libtag.so.1
├── libusb-1.0.so.0
├── libva-drm.so.2
└── libva.so.2

2 directories, 62 files
vainfo
Trying display: wayland
Trying display: x11
vainfo: VA-API version: 1.18 (libva 2.18.1)
vainfo: Driver version: Mesa Gallium driver 23.0.2 for AMD Radeon RX 7900 XT (gfx1100, LLVM 15.0.7, DRM 3.52, 6.3.5-2-MANJARO)
vainfo: Supported profile and entrypoints
      VAProfileH264ConstrainedBaseline:	VAEntrypointVLD
      VAProfileH264ConstrainedBaseline:	VAEntrypointEncSlice
      VAProfileH264Main               :	VAEntrypointVLD
      VAProfileH264Main               :	VAEntrypointEncSlice
      VAProfileH264High               :	VAEntrypointVLD
      VAProfileH264High               :	VAEntrypointEncSlice
      VAProfileHEVCMain               :	VAEntrypointVLD
      VAProfileHEVCMain               :	VAEntrypointEncSlice
      VAProfileHEVCMain10             :	VAEntrypointVLD
      VAProfileHEVCMain10             :	VAEntrypointEncSlice
      VAProfileJPEGBaseline           :	VAEntrypointVLD
      VAProfileVP9Profile0            :	VAEntrypointVLD
      VAProfileVP9Profile2            :	VAEntrypointVLD
      VAProfileAV1Profile0            :	VAEntrypointVLD
      VAProfileNone                   :	VAEntrypointVideoProc

Also still unable to hardware transcode on AMDGPU on any version after 1.32.1.6999. Rolling back to 1.32.1.6999 fixes the issue entirely, and I am able to hardware encode on AMDGPU. I have properly exposed /dev/dri in my docker container. Here are logs from build 6999 as well as 7210.

Plex Media Server Logs_2023-06-21_08-03-17 - v1.32.5.7210-77f7f99fa.zip (20.1 KB)
Plex Media Server Logs_2023-06-21_08-58-06 - v1.32.1.6999-91e1e2e2c.zip (13.7 KB)

You can see in the logs the following errors in 7210, which do not exist in 6999:

[AVHWDeviceContext @ 0x7fb39eaee0c0] Failed to initialise VAAPI connection: -1 (unknown libva error).

Failed to set value ‘vaapi=vaapi:’ for option ‘init_hw_device’: Error number -5 occurred

Failed to set value ‘vaapi=vaapi:’ for option ‘init_hw_device’: I/O error

I ran the following command to ensure the APDGPU driver was working correctly in my docker container:

docker exec -it -e LIBVA_DRIVERS_PATH=/vaapi-amdgpu/lib/dri -e LD_LIBRARY_PATH=/vaapi-amdgpu/lib plex \
/lib/plexmediaserver/Plex\ Transcoder -hide_banner -loglevel debug -vaapi_device /dev/dri/renderD128

Here is the output:

Splitting the commandline.
Reading option ‘-hide_banner’ … matched as option ‘hide_banner’ (do not show program banner) with argument ‘1’.
Reading option ‘-loglevel’ … matched as option ‘loglevel’ (set logging level) with argument ‘debug’.
Reading option ‘-vaapi_device’ … matched as option ‘vaapi_device’ (set VAAPI hardware device (DRM path or X11 display name)) with argument ‘/dev/dri/renderD128’.
Finished splitting the commandline.
Parsing a group of options: global .
Applying option hide_banner (do not show program banner) with argument 1.
Applying option loglevel (set logging level) with argument debug.
Applying option vaapi_device (set VAAPI hardware device (DRM path or X11 display name)) with argument /dev/dri/renderD128.
[AVHWDeviceContext @ 0x7efc92e78d00] libva: VA-API version 1.17.0
[AVHWDeviceContext @ 0x7efc92e78d00] libva: Trying to open /vaapi-amdgpu/lib/dri/radeonsi_drv_video.so
[AVHWDeviceContext @ 0x7efc92e78d00] libva: Found init function __vaDriverInit_1_17
[AVHWDeviceContext @ 0x7efc92e78d00] libva: va_openDriver() returns 0
[AVHWDeviceContext @ 0x7efc92e78d00] Initialised VAAPI connection: version 1.17
[AVHWDeviceContext @ 0x7efc92e78d00] Format 0x3231564e → nv12.
[AVHWDeviceContext @ 0x7efc92e78d00] Format 0x30313050 → p010le.
[AVHWDeviceContext @ 0x7efc92e78d00] Format 0x36313050 → unknown.
[AVHWDeviceContext @ 0x7efc92e78d00] Format 0x30323449 → yuv420p.
[AVHWDeviceContext @ 0x7efc92e78d00] Format 0x32315659 → yuv420p.
[AVHWDeviceContext @ 0x7efc92e78d00] Format 0x56595559 → unknown.
[AVHWDeviceContext @ 0x7efc92e78d00] Format 0x32595559 → yuyv422.
[AVHWDeviceContext @ 0x7efc92e78d00] Format 0x59565955 → uyvy422.
[AVHWDeviceContext @ 0x7efc92e78d00] Format 0x30303859 → gray.
[AVHWDeviceContext @ 0x7efc92e78d00] Format 0x50343434 → yuv444p.
[AVHWDeviceContext @ 0x7efc92e78d00] Format 0x41524742 → bgra.
[AVHWDeviceContext @ 0x7efc92e78d00] Format 0x41424752 → rgba.
[AVHWDeviceContext @ 0x7efc92e78d00] Format 0x58524742 → bgr0.
[AVHWDeviceContext @ 0x7efc92e78d00] Format 0x58424752 → rgb0.
[AVHWDeviceContext @ 0x7efc92e78d00] VAAPI driver: Mesa Gallium driver 22.3.6 for AMD Ryzen Embedded V1756B with Radeon Vega Gfx (raven, LLVM 15.0.7, DRM 3.49, 6.1.0-0.deb11.7-amd64).
[AVHWDeviceContext @ 0x7efc92e78d00] Driver not found in known nonstandard list, using standard behaviour.
Successfully parsed a group of options.
Hyper fast Audio and Video encoder
usage: ffmpeg [options] [[infile options] -i infile]… {[outfile options] outfile}…

Let me know if there’s anything else that could help resolve this issue.

I have also used the new pull-down menu to select the proper hardware transcoder from the list, saved, and restarted the docker container, but no change. Same errors & not working:

@rahzadan

Is the PUID/PLEX_UID a member of the group which owns the nodes (renderD128, etc?)

It’s working flawlessly here on Intel i7-8809G (dual GPU machine)

@ChuckPa

Thanks for your response. Here is my docker compose:

version: “2.1”
services:
plex:
image: lscr.io/linuxserver/plex:latest
container_name: plex
network_mode: host
group_add:
- “106”
- “44”
environment:
- PUID=1000
- PGID=100
- TZ=Canada/Atlantic
- VERSION=latest
- DOCKER_MODS=jefflessard/plex-vaapi-amdgpu-mod
devices:
- /dev/dri/
volumes:
- /srv/dev-disk-by-uuid-f150e77a-a744-4146-b9e3-25f6530e62f9/plex/config:/config
- /srv/dev-disk-by-uuid-f150e77a-a744-4146-b9e3-25f6530e62f9/plex/content:/content
- /tmp:/transcode
restart: unless-stopped

You can see that I’ve done a “group_add” to ensure that the “render” and “video” groups are added to PUID 1000.

After running the following:

cat /etc/group

It shows, among others, video:x:44: and render:x:106:

I have also confirmed that both /dev/dri devices have their groups added to PUID 1000.

drwxr-xr-x 3 root root 100 Jun 5 22:15 .
drwxr-xr-x 17 root root 3460 Jun 5 22:15 …
drwxr-xr-x 2 root root 80 Jun 5 22:15 by-path
crw-rw---- 1 root video 226, 0 Jun 5 22:15 card0
crw-rw---- 1 root render 226, 128 Jun 5 22:15 renderD128

Note that again, everything is working fine in PMS 1.32.1.6999 with this config. Any version newer than this does not.

I also tried the following under devices:

/dev/dri/
/dev/dri/renderD128
/dev/dri/card0

You no longer need ANY 3rd party VAAPI mods in docker containers or native installations.

Everything is native to PMS

This was tested on redhat, ubuntu, debian, fedora, and in containers several weeks (almost 2 months ago) with complete success.

2 Likes

@ChuckPa

THANK YOU!

Removing the 3rd party VVAPI mod and the group_add entries fixed the issue, and now hw transcoding is working again! On version 1,32,1,6999 and below, I needed the mod for hw transcoding to work. Also, it seems the ‘abc’ user within the container is properly assigned to the correct groups without the need for group_add, which was previously required.

Is there any documentation that states that 3rd party VVAPI mods aren’t needed anymore? I assume that became the case after 1.32.1.6999?

This capability is new. Until now, there is no Official AMD support.

With this release, AMD support is native and requires no special consideration.

Not sure how to address “Stop that hack you were doing!!”

1 Like

@ChuckPa

I did see the official AMD support in the changelog, but not until this very recent release (1.32.5.7210). My issue started on 1.32.2.7002, before official AMD support was (announced as being) added.

That being said, even with this new version it didn’t occur to me to try to remove the VVAPI mod as I’d always needed it before.

Thanks again!

The AMD support was completed sometime around the 1.32.2 timeframe :wink:
There’s been a lot of testing needed.

1 Like

That explains it.

Cheers!

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