Problems with HW transcode of HDR content on Intel 12th Gen (12600k)

Server Version#: 1.25.1.5286
Player Version#: Using Chrome (96.0.4664.45) Web version 4.71.0
HW: Intel 12600k

I am using the official docker container (“plexpass” variant) on Ubuntu 20.04. In addition I am running a custom build of kernel 5.16.0-rc2-custom to enable full support for the CPU and peripherals. DRI nodes (/dev/dri) are mapped into the container.

HW transcoding SDR 4k content works beautifully but when I try to play back any HDR content it fails and I see the following in the kernel log (dmesg):

[ 2794.709032] i915 0000:00:02.0: [drm] Resetting vcs0 for preemption time out
[ 2794.711329] i915 0000:00:02.0: [drm] GPU HANG: ecode 12:4:28fffffd, in Plex Transcoder [51622]
[ 2803.076590] i915 0000:00:02.0: [drm] GPU HANG: ecode 12:4:28fffffd, in Plex Transcoder [51622]
[ 2803.077611] i915 0000:00:02.0: [drm] Resetting vcs0 for stopped heartbeat on vcs0
[ 2803.078157] i915 0000:00:02.0: [drm] Resetting chip for stopped heartbeat on vcs0
[ 2803.180055] [drm:__uc_sanitize [i915]] *ERROR* Failed to reset GuC, ret = -110
[ 2803.273118] i915 0000:00:02.0: [drm] *ERROR* Failed to reset chip
[ 2803.273132] i915 0000:00:02.0: [drm:add_taint_for_CI [i915]] CI tainted:0x9 by intel_gt_reset+0x24f/0x2c0 [i915]
[ 2803.376059] [drm:__uc_sanitize [i915]] *ERROR* Failed to reset GuC, ret = -110
[ 2803.377916] i915 0000:00:02.0: [drm] Plex Transcoder[51622] context reset due to GPU hang
[ 2803.520212] show_signal_msg: 42 callbacks suppressed
[ 2803.520216] Plex Media Serv[51097]: segfault at 0 ip 0000000000000000 sp 00007f5355652788 error 14
[ 2803.520221] Code: Unable to access opcode bytes at RIP 0xffffffffffffffd6.
[ 2807.637534] Fence expiration time out i915-0000:00:02.0:Plex Transcoder[51622]:21ac!
[ 3254.147304] Attempt to set a LOCK_MAND lock via flock(2). This support has been removed and the request ignored.
[ 3955.711097] Plex Media Serv[64313]: segfault at 0 ip 0000000000000000 sp 00007f3f7d339018 error 14
[ 3955.711103] Code: Unable to access opcode bytes at RIP 0xffffffffffffffd6.
[ 3963.976659] Plex Media Serv[64496]: segfault at 0 ip 0000000000000000 sp 00007effbcab6018 error 14
[ 3963.976666] Code: Unable to access opcode bytes at RIP 0xffffffffffffffd6.
[ 3972.014925] Plex Media Serv[64783]: segfault at 0 ip 0000000000000000 sp 00007f1d6e5d7e28 error 14
[ 3972.014946] Code: Unable to access opcode bytes at RIP 0xffffffffffffffd6.

Since this only happens with HDR content I wonder if this has something to do with the tone mapping, perhaps using OpenCL?

I also installed PMS without docker and upgraded all the Intel graphics/dri/drm/OCL stack from their repo to see if these versions behave differently. So far no difference.

The file I’m trying to play is LG: New York HDR UHD 4K Demo | 4K Media

I’m happy to provide more information and logs if that would help.

Can you confirm if this is specific to tone mapping, or if it applies to all 10-bit HEVC content?

These errors largely look like kernel issues. This sometimes happens with very new chips; the driver support generally don’t stabilize until a bit after release. You’ll probably want to report to the upstream driver devs.

Hi Ridley,

I’d be happy to. Can you point me to a video that would be a good test for that?

I was under the impression that all HDR content would have to be mapped for 8-bit presentation. :slight_smile:

I’ll see if I can find the correct channel to report this upstream.

What I interpret as what Ridley means, if you turn off tone mapping in PMS, and then try transcoding, do you get the same errors, different errors, or does hw work when tone mapping is off ?

Thank you for the clarification @TeknoJunky ! It seems that when I disable the tone mapping, the HW transcode works Ok but as expected, some content looks washed out or otherwise strange.

@Ridley can you elaborate on this so I can write a bug report upstream. Is OpenCL used here?

washed out content is by product of hdr to sdr conversion without mapping the larger color/brightness space onto the lower sdr color space.

tone mapping, is what does the color space conversion, so that hdr to sdr has ‘normal’ looking color.

so by your response, it appears that the errors seem to be specific to the tone mapping conversion, which should help narrow down the problem(s).

I’ll leave any further elaboration to Ridley or anyone else that may be able to help.

(edit: I guess I mis-read, you already understood all that, so the above is just fyi for anyone following along who didn’t)

1 Like

Not quite what I meant (some 10-bit content isn’t HDR at all), but it’s an equivalent test regardless :slight_smile:

Yes, tone mapping in Plex on Intel GPUs is done via OpenCL (i.e. the Intel Compute Runtime driver). It’s possible that you might have a Plex-specific issue in addition to whatever’s causing those kernel errors; I might be able to get a bit more information by looking over your server logs.

Thank you @Ridley, I will send you some logs I have. I’m not sure if they have anything sensitive in them so I’ll PM them your way.

Dec 02, 2021 19:43:04.762 [0x7f697d648b38] ERROR - [Transcoder] [AVHWDeviceContext @ 0x7f3bcef27d40] No matching devices found.

Looks like we’re failing to locate an OpenCL device corresponding to your GPU. This could be due to a CL driver issue. Try running this on the command line for some additional diagnostics:

EnableExtendedVaFormats='1' FFMPEG_EXTERNAL_LIBS='/config/Library/Application\ Support/Plex\ Media\ Server/Codecs/fb9eae3-4185-linux-x86_64/' LIBVA_DRIVERS_PATH='/usr/lib/plexmediaserver/lib/dri' NEOReadDebugKeys='1' '/usr/lib/plexmediaserver/Plex Transcoder' '-codec:#0x101' 'hevc' '-hwaccel:#0x101' 'vaapi' '-hwaccel_fallback_threshold:#0x101' '10' '-hwaccel_output_format:#0x101' 'vaapi' '-hwaccel_device:#0x101' 'vaapi' '-analyzeduration' '20000000' '-probesize' '20000000' '-i' 'LG New York HDR UHD 4K Demo.ts' '-filter_complex' '[0:#0x101]hwupload[0];[0]scale_vaapi=w=2276:h=1280:format=p010[1];[1]hwmap=derive_device=opencl[2];[2]tonemap_opencl=tonemap=mobius:format=nv12:m=bt709:p=bt709:r=tv[3];[3]hwmap=derive_device=vaapi:reverse=1[4];[4]hwupload[5]' '-map' '[5]' '-codec:0' 'h264_vaapi' '-b:0' '61530k' '-maxrate:0' '82040k' '-bufsize:0' '164080k' '-r:0' '25' '-force_key_frames:0' 'expr:gte(t,n_forced*1)' -f null /dev/null '-start_at_zero' '-copyts' '-vsync' 'cfr' '-init_hw_device' 'vaapi=vaapi:' '-filter_hw_device' 'vaapi' '-y' '-nostats' '-loglevel' trace

A log is attached.

Is it from this place:

[AVHWDeviceContext @ 0x7f01a2080ec0] 2 OpenCL platforms found.
[AVHWDeviceContext @ 0x7f01a2080ec0] platform_version does not match ("OpenCL 3.0 ").
beignet-opencl-icd: no supported GPU found, this is probably the wrong opencl-icd package for this hardware
(If you have multiple ICDs installed and OpenCL works, you can ignore this message)
[AVHWDeviceContext @ 0x7f01a2080ec0] No devices found on platform "Intel Gen OCL Driver".
[AVHWDeviceContext @ 0x7f01a2080ec0] No matching devices found.
[AVHWDeviceContext @ 0x7f01a2080ec0] 2 OpenCL platforms found.
[AVHWDeviceContext @ 0x7f01a2080ec0] 0.0: Intel(R) OpenCL HD Graphics / Intel(R) Graphics [0x4680]
[AVHWDeviceContext @ 0x7f01a2080ec0] Platform Intel Gen OCL Driver does not export the VAAPI device enumeration function.
[AVHWDeviceContext @ 0x7f01a2080ec0] Beignet DRM to OpenCL image mapping function not found (clCreateImageFromFdINTEL).
[AVHWDeviceContext @ 0x7f01a2080ec0] Beignet DRM to OpenCL mapping not usable.
[AVHWDeviceContext @ 0x7f01a2080ec0] cl_intel_va_api_media_sharing found as platform extension.
[AVHWDeviceContext @ 0x7f01a2080ec0] Intel QSV to OpenCL mapping function found (clCreateFromVA_APIMediaSurfaceINTEL).
[AVHWDeviceContext @ 0x7f01a2080ec0] Intel QSV in OpenCL acquire function found (clEnqueueAcquireVA_APIMediaSurfacesINTEL).
[AVHWDeviceContext @ 0x7f01a2080ec0] Intel QSV in OpenCL release function found (clEnqueueReleaseVA_APIMediaSurfacesINTEL).

log.txt (97.5 KB)

@kuikkaj did you fix this? Same issue on new 12600 based system for me

Hi,

I have not found a solution yet, other than disabling tone mapping which has other undesirable side effects as described above.

@Ridley do you have any thoughts about the log?

Juha

I went off the beaten path a bit and pulled in 5.15 kernel with mixed results. I can get Plex to transcode a 4K HDR 10bit file (tone mapping enabled) but it will end up with crazy artifacts (green/white) squares across frames.

attached my full logs for running @Ridley diagnostic test (looks successful?)

/snip

frame= 1806 fps= 78 q=-0.0 Lsize=N/A time=00:00:00.00 bitrate=N/A speed=   0x    
video:520523kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
Input file #0 (LG New York HDR UHD 4K Demo.ts):
  Input stream #0:0 (video): 1806 packets read (451498845 bytes); 1806 frames decoded; 
  Input stream #0:1 (audio): 0 packets read (0 bytes); 
  Total: 1806 packets (451498845 bytes) demuxed
Output file #0 (/dev/null):
  Output stream #0:0 (video): 1806 frames encoded; 1806 packets muxed (533015217 bytes); 
  Total: 1806 packets (533015217 bytes) muxed
1806 frames successfully decoded, 0 decoding errors
[h264_vaapi @ 0x7f6e7f18d580] Freed output buffer 0x2
[AVIOContext @ 0x7f6e7f1ad040] Statistics: 492578640 bytes read, 4 seeks

plex_test.txt (6.1 MB)

@Ridley did you ever get a chance to circle back on this? I went and got an Nvidia P4 card so I can do HW stable transcoding but basically wasted buying the new 12th Gen Intel chip until this works.

Happy to help debug if needed…

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