Windows-Containers icon indicating copy to clipboard operation
Windows-Containers copied to clipboard

Support 3rd Party Vendor Specific Graphics APIs

Open sikhness opened this issue 1 year ago • 15 comments

Currently GPU Acceleration within Windows Containers only allow for DirectX and frameworks built on top of it. Please allow for a way for us to leverage 3rd party Vendor specific frameworks (such as AMD AMF, ROCM, CUDA, and etc) to truly allow for GPU accelerated workloads.

sikhness avatar May 31 '24 01:05 sikhness

Thanks for the request @sikhness. I want to understand a bit more the use case behind this request, what sort of apps / tools are you trying to use that requires 3rd party vendor frameworks?

fady-azmy-msft avatar Jun 04 '24 14:06 fady-azmy-msft

Hi @fady-azmy-msft! It would be useful for anything that requires video encoding/decoding capabilities such as a Media Server like Plex. Currently they can only use DirectX based encoding/decoding capabilities, but AMD, Intel and Nvidia offer AMF, QuickSync and NVENC respectively that many applications do use. In fact, not many applications use DirectX for this.

The same applies for AI based GPU workloads such as Ollama and AnythingLLM. None of these along with many others use DirectML (which is supported by Windows Containers), but they do use third party frameworks to use GPU acceleration such as AMD's ROCM and Nvidia's CUDA.

There's also some work done in the past by some people trying to get Unreal Engine Containers working on Windows with vendor specific graphics drivers, but it seems very convoluted and I was never able to get it working.

sikhness avatar Jun 05 '24 00:06 sikhness

Creating a thread internally to discuss this feature request: 🔖 51837974

ntrappe-msft avatar Jun 17 '24 18:06 ntrappe-msft

All of these APIs are supported, I think you can close this ticket.

Vendor specific frameworks (such as AMD AMF, ROCM, CUDA, and etc) to truly allow for GPU accelerated workloads.

Please visit "Enabling vendor-specific graphics APIs in Windows containers"

https://github.com/UnrealContainers/unrealcontainers.github.io/blob/23778bdd91c3c57a3a7258ca7e9201dd84d0510f/collections/_posts/2021-07-23-enabling-vendor-specific-graphics-apis-in-windows-containers.md

Good luck out there!

doctorpangloss avatar Jul 11 '24 15:07 doctorpangloss

@doctorpangloss , it states in the article that you posted (which I also posted in my previous reply) that this is an unofficial way and isn't actually supported by Microsoft. Furthermore, it is 3 years out of date, and I personally was not able to get it working (I did try and it was very involved).

I'm asking for an official method of having this working similar to how DirectX just works or at least officially documented on how to get it working if it involves any extra steps and such.

sikhness avatar Jul 11 '24 18:07 sikhness

and I personally was not able to get it working (I did try and it was very involved).

what specifically are you trying to do? I run CUDA and AMF workloads using the exactly described steps in GPU enabled Windows containers all the time.

doctorpangloss avatar Jul 11 '24 18:07 doctorpangloss

maybe start with FROM their-docker-image and docker run -it --device class/...theguid they talk about... and see for yourself, it will all work fine

doctorpangloss avatar Jul 11 '24 18:07 doctorpangloss

Thanks for the info @doctorpangloss, do you happen to have a working Dockerfile or compose file for AMF that you've configured and are able to share?

sikhness avatar Jul 11 '24 18:07 sikhness

any of the results from here will work https://github.com/search?q=xcopy+%2Fy+C%3A%5CWindows%5CSystem32%5Cavicap32.dll+C%3A%5CGatheredDlls%5C&type=code

https://github.com/realAYAYA/UnrealEngine-ToonLit/blob/ffb49957289bf414554c32303c75bfc50aca537c/UnrealEngine/Engine/Extras/Containers/Dockerfiles/windows/runtime/Dockerfile

doctorpangloss avatar Jul 11 '24 20:07 doctorpangloss

Adding to list of feature requests.

ntrappe-msft avatar Oct 15 '24 17:10 ntrappe-msft

Thanks @ntrappe-msft.

While we're waiting for this to hopefully be added officially, @doctorpangloss have you been actually able to get AMF working recently with Windows Server 2025 containers? I decided to take another crack at trying to make them work inside of process isolated Windows Containers, the good part is that all the driver DLLs seem to be copied automatically without needing to paste them like in the links you provided. However, when I actually run an AMF based encode job via ffmpeg, I get a DLL amfrt64.dll failed to open without anymore details. If I run the same encode job natively on the machine, it works of course.

Any idea how you got this working?

sikhness avatar Jan 06 '25 23:01 sikhness

I've been working through this today to try to get somewhere with this (manually if possible) and it seems like there is something within Containers possibly that's restricting external frameworks?

I was able to overcome my above issue by simply copying all of the DLLs and renaming a few directly to the System32 folder within the container, however I hit a roadblock then which I can try to describe.

I tried to emulate the same thing I'm doing on a Windows Server based VM using GPU-P similar to how it is described here, and after moving the respective driver files within the VM to the HostDriverStore and System32 folder respectively, AMD's AMF just simply worked!

However, when I do something similar from the host but inside of a process isolated Container, I just keep getting caught with errors. Would anyone be able to shine a light on this?

Here is the log from the Container of when I try to encode something through ffmpeg using hevc_amf.

[hevc_amf @ 000001b59ddf4ec0] Using device d3d11va0 (type d3d11va) with hevc_amf encoder.
[hevc @ 000001b59ddb0700] Decoded frame with POC 0/27.
[hevc @ 000001b59ddb0ac0] nal_unit_type: 1(TRAIL_R), nuh_layer_id: 0, temporal_id: 0
[hevc @ 000001b59ddb0ac0] Output frame with POC 0/18.
[hevc @ 000001b59ddb0ac0] Decoded frame with POC 0/23.
[hevc @ 000001b59de3a400] nal_unit_type: 0(TRAIL_N), nuh_layer_id: 0, temporal_id: 0
[hevc @ 000001b59de3a400] Output frame with POC 0/19.
[hevc @ 000001b59de3a400] Decoded frame with POC 0/19.
[hevc @ 000001b59de3a7c0] nal_unit_type: 0(TRAIL_N), nuh_layer_id: 0, temporal_id: 0
[hevc @ 000001b59de3a7c0] Output frame with POC 0/20.
[hevc @ 000001b59de3a7c0] Decoded frame with POC 0/20.
[hevc @ 000001b59de3ab80] nal_unit_type: 0(TRAIL_N), nuh_layer_id: 0, temporal_id: 0
[hevc @ 000001b59de3ab80] Output frame with POC 0/21.
[hevc @ 000001b59de3ab80] Decoded frame with POC 0/21.
[hevc @ 000001b59de38e00] nal_unit_type: 0(TRAIL_N), nuh_layer_id: 0, temporal_id: 0
[hevc @ 000001b59de38e00] Output frame with POC 0/22.
[hevc_amf @ 000001b59ddf4ec0] EncodeCoreHelper: 2025-01-07 16:12:03.837    177F0 [EncodeCoreHelper] Warning: ***Failed to find 
regpath, using default=1
[hevc_amf @ 000001b59ddf4ec0] EncodeQueueWinImpl: 2025-01-07 16:12:03.838    177F0 [EncodeQueueWinImpl]   Error: ..\..\..\..\..
\runtime\src\components\EncoderCore\EncodeQueueWinImpl.cpp(316):AMF_ERROR 1 : AMF_FAIL: EncodeQueueServiceWin::Initialize() Fai
led to Load EncodeCore binary.
[hevc_amf @ 000001b59ddf4ec0] EncodeQueueService: 2025-01-07 16:12:03.838    177F0 [EncodeQueueService] Warning: Failed to crea
te encode queue serivce.
[hevc_amf @ 000001b59ddf4ec0] AMFEncoderCoreBaseImpl: 2025-01-07 16:12:03.838    177F0 [AMFEncoderCoreBaseImpl] Warning: Failed
 to initialize EncodeQueueFactory.
[hevc_amf @ 000001b59ddf4ec0] AMFEncoderCoreBaseImpl: 2025-01-07 16:12:03.840    177F0 [AMFEncoderCoreBaseImpl] Warning: Failed
 to create encode queue serivce.
[hevc_amf @ 000001b59ddf4ec0] AMFEncoderCoreHevc: 2025-01-07 16:12:03.840    177F0 [AMFEncoderCoreHevc] Warning: Encode Core dl
l not found, fall back to UVE path
[hevc @ 000001b59de38e00] Decoded frame with POC 0/22.
[hevc_amf @ 000001b59ddf4ec0] AMFEncoderCoreHevc: 2025-01-07 16:12:03.840    177F0 [AMFEncoderCoreHevc] Warning: CreateServices
 failed.
[hevc @ 000001b59de38300] nal_unit_type: 0(TRAIL_N), nuh_layer_id: 0, temporal_id: 0
[hevc_amf @ 000001b59ddf4ec0] AMFEncoderCoreHevc: 2025-01-07 16:12:03.840    177F0 [AMFEncoderCoreHevc]    Info: *****Fallback 
to UVE path!
[hevc @ 000001b59de38300] Output frame with POC 0/23.
[hevc_amf @ 000001b59ddf4ec0] AMFEncoderCoreHevc: 2025-01-07 16:12:03.841    177F0 [AMFEncoderCoreHevc]   Debug: AMFEncoderCore
HevcImpl::Terminate()
[hevc_amf @ 000001b59ddf4ec0] AMFEncoderHEVC: 2025-01-07 16:12:03.841    177F0 [AMFEncoderHEVC]   Error: ..\..\..\..\..\runtime
\src\components\EncoderUVE\EncoderUVEHEVCImpl.cpp(127):Failed to get UVEHEVC version.
[hevc_amf @ 000001b59ddf4ec0] AMFEncoderHEVC: 2025-01-07 16:12:03.841    177F0 [AMFEncoderHEVC]   Error: ..\..\..\..\..\runtime
\src\components\EncoderUVE\EncoderUVEHEVCImpl.cpp(1007):Assertion failed:InitUVEHevc() UVEHEVC version mismatch
[hevc_amf @ 000001b59ddf4ec0] AMFEncoderHEVC: 2025-01-07 16:12:03.841    177F0 [AMFEncoderHEVC]    Info: Prepare() - Failed to 
init uveHEVC service
[hevc_amf @ 000001b59ddf4ec0] AMFEncoderHEVC: 2025-01-07 16:12:03.841    177F0 [AMFEncoderHEVC]   Debug: AMFEncoderUVEHEVCImpl:
:Terminate()
[hevc_amf @ 000001b59e409a80] CreateComponent(AMFVideoEncoderHW_HEVC) failed with error 10
[hevc @ 000001b59de38300] Decoded frame with POC 0/24.
[hevc @ 000001b59de39540] nal_unit_type: 0(TRAIL_N), nuh_layer_id: 0, temporal_id: 0
[hevc @ 000001b59de39540] Output frame with POC 0/24.
[vost#0:0/hevc_amf @ 000001b59dd9fa80] Error while opening encoder - maybe incorrect parameters such as bit_rate, rate, width o
r height.
[vf#0:0 @ 000001b59e21bcc0] Error sending frames to consumers: Encoder not found
[vf#0:0 @ 000001b59e21bcc0] Task finished with error code: -1129203192 (Encoder not found)
[vf#0:0 @ 000001b59e21bcc0] Terminating thread with return code -1129203192 (Encoder not found)
[vost#0:0/hevc_amf @ 000001b59dd9fa80] Encoder thread received EOF
[vost#0:0/hevc_amf @ 000001b59dd9fa80] Could not open encoder before EOF
[vost#0:0/hevc_amf @ 000001b59dd9fa80] Task finished with error code: -22 (Invalid argument)
[vost#0:0/hevc_amf @ 000001b59dd9fa80] Terminating thread with return code -22 (Invalid argument)
[vist#0:0/hevc @ 000001b59e2b2bc0] [dec:hevc @ 000001b59e258c40] Decoder returned EOF, finishing
[vist#0:0/hevc @ 000001b59e2b2bc0] [dec:hevc @ 000001b59e258c40] Terminating thread with return code 0 (success)
[vist#0:0/hevc @ 000001b59e2b2bc0] All consumers of this stream are done
[in#0/matroska,webm @ 000001b59dd6ecc0] Terminating thread with return code 0 (success)

sikhness avatar Jan 07 '25 21:01 sikhness

This issue has been open for 90 days with no updates. no assignees, please provide an update or close this issue.

This issue has been open for 90 days with no updates. no assignees, please provide an update or close this issue.

This issue has been open for 90 days with no updates. no assignees, please provide an update or close this issue.