onnxruntime/tools/ci_build/github/azure-pipelines
Yulong Wang 8680244ebc
Fix delay load for WebGPU EP and DML EP (#23111)
### Description

This change fixes the DLL delay load problem for the WebGPU EP and
DirectML EP. See detailed explanation below.

### Problem

When onnxruntime.dll uses delay loading for its dependencies, the
dependencies are loaded using `LoadLibraryEx()`, which search the
directory of process (.exe) instead of this library (onnxruntime.dll).
This is a problem for usages of Node.js binding and python binding,
because Windows will try to find the dependencies in the directory of
node.exe or python.exe, which is not the directory of onnxruntime.dll.

There was previous attempt to fix this by loading DirectML.dll in the
initialization of onnxruntime nodejs binding, which works for DML EP but
is not a good solution because it does not really "delay" the load.

For WebGPU, the situation became worse because webgpu_dawn.dll depends
on dxil.dll and dxcompiler.dll, which are explicitly dynamically loaded
in the code using `LoadLibraryA()`. This has the same problem of the DLL
search.

### Solutions

For onnxruntime.dll loading its direct dependencies, it can be resolved
by set the [`__pfnDliNotifyHook2`
hook](https://learn.microsoft.com/en-us/cpp/build/reference/understanding-the-helper-function?view=msvc-170#structure-and-constant-definitions)
to load from an absolute path that constructed from the onnxruntime.dll
folder and the DLL name.

For webgpu_dawn.dll loading dxil.dll and dxcompiler.dll, since they are
explicitly loaded in the code, the hook does not work. Instead, it can
be resolved by ~~using WIN32 API `SetDllDirectory()` to add the
onnxruntime.dll folder to the search path.~~ preloading the 2 DLLs from
the onnxruntime.dll folder .
2024-12-19 10:23:48 -08:00
..
nodejs/templates Update pool to MacOS-13 (#17361) 2024-09-17 10:07:30 -07:00
nuget [TensorRT EP] Refactor TRT version update logic & apply TRT 10.5 (#22483) 2024-10-29 09:23:41 -07:00
stages Revert DML pipeline changes (#23135) 2024-12-18 10:42:10 -08:00
templates Revert DML pipeline changes (#23135) 2024-12-18 10:42:10 -08:00
triggers
android-arm64-v8a-QNN-crosscompile-ci-pipeline.yml [QNN EP] QNN SDK 2.28.2 (#22844) 2024-11-18 20:10:36 -08:00
android-x86_64-crosscompile-ci-pipeline.yml Update pool to MacOS-13 (#17361) 2024-09-17 10:07:30 -07:00
bigmodels-ci-pipeline.yml bigmodel pipeline update cp38 to cp310 (#22793) 2024-11-21 07:25:01 -08:00
binary-size-checks-pipeline.yml Clean up some mobile package related files and their usages. (#21606) 2024-08-05 16:38:20 -07:00
build-perf-test-binaries-pipeline.yml Refactor cuda packaging pipeline (#22542) 2024-10-23 08:14:10 -07:00
c-api-noopenmp-packaging-pipelines.yml Override android qnn sdk version with pipeline param (#22895) 2024-11-25 21:01:05 -08:00
c-api-training-packaging-pipelines.yml Move on-device training packages publish step (#21539) 2024-07-29 09:59:46 -07:00
cuda-packaging-pipeline.yml Update the Docker image version (#22907) 2024-11-21 19:38:39 +08:00
linux-ci-pipeline.yml Update the Docker image version (#22907) 2024-11-21 19:38:39 +08:00
linux-cpu-minimal-build-ci-pipeline.yml Replace reference to python 3.8 with python 3.10 (#22692) 2024-11-07 16:51:40 -08:00
linux-dnnl-ci-pipeline.yml Update DNNL CI python to 310 (#22691) 2024-11-05 09:14:48 -08:00
linux-gpu-ci-pipeline.yml Update the Docker image version (#22907) 2024-11-21 19:38:39 +08:00
linux-gpu-tensorrt-ci-pipeline.yml Update the Docker image version (#22907) 2024-11-21 19:38:39 +08:00
linux-gpu-tensorrt-daily-perf-pipeline.yml [TensorRT EP] Refactor TRT version update logic & apply TRT 10.5 (#22483) 2024-10-29 09:23:41 -07:00
linux-migraphx-ci-pipeline.yml [ROCm] Python 3.10 in ROCm CI, and ROCm 6.2.3 in MigraphX CI (#22527) 2024-10-25 11:47:16 -07:00
linux-openvino-ci-pipeline.yml OVEP 1.21.0 Development Updates (#23080) 2024-12-11 22:26:32 -08:00
linux-qnn-ci-pipeline.yml [QNN EP] QNN SDK 2.28.2 (#22844) 2024-11-18 20:10:36 -08:00
linux-rocm-ci-pipeline.yml [ROCm] Python 3.10 in ROCm CI, and ROCm 6.2.3 in MigraphX CI (#22527) 2024-10-25 11:47:16 -07:00
mac-ci-pipeline.yml Add a reminder in set-trigger-rules script (#21929) 2024-08-30 12:18:10 -07:00
mac-coreml-ci-pipeline.yml Update pool to MacOS-13 (#17361) 2024-09-17 10:07:30 -07:00
mac-ios-ci-pipeline.yml Specify iOS simulator runtime version (#22474) 2024-10-18 09:26:06 -07:00
mac-ios-packaging-pipeline.yml Update pool to MacOS-13 (#17361) 2024-09-17 10:07:30 -07:00
mac-react-native-ci-pipeline.yml Re-enable codesign for maven packages (#22308) 2024-10-04 14:30:17 -07:00
npm-packaging-pipeline.yml Re-enable codesign for maven packages (#22308) 2024-10-04 14:30:17 -07:00
nuget-cuda-publishing-pipeline.yml Set CUDA12 as default in GPU packages (#21438) 2024-07-25 10:17:16 -07:00
nuget-windows-ai.yml Nuget Windows AI Pipeline, Disable SDL Submodules. (#22711) 2024-11-04 08:39:28 -08:00
post-merge-jobs.yml [TensorRT EP] Refactor TRT version update logic & apply TRT 10.5 (#22483) 2024-10-29 09:23:41 -07:00
publish-nuget.yml Move on-device training packages publish step (#21539) 2024-07-29 09:59:46 -07:00
py-cuda-alt-package-test-pipeline.yml Update the Docker image version (#22907) 2024-11-21 19:38:39 +08:00
py-cuda-alt-packaging-pipeline.yml Add pipauth to more ADO pipelines and enable CSV (#22612) 2024-10-28 16:39:22 -07:00
py-cuda-package-test-pipeline.yml Update the Docker image version (#22907) 2024-11-21 19:38:39 +08:00
py-cuda-packaging-pipeline.yml Enable CUDA Python Test (#22717) 2024-11-05 16:26:50 -08:00
py-cuda-publishing-pipeline.yml Set CUDA12 as default in GPU packages (#21438) 2024-07-25 10:17:16 -07:00
py-dml-packaging-pipeline.yml Add pipauth to more ADO pipelines and enable CSV (#22612) 2024-10-28 16:39:22 -07:00
py-package-build-pipeline.yml
py-package-test-pipeline.yml Adding new Python package testing pipeline for Cuda Alt (#22584) 2024-10-24 19:24:53 -07:00
py-packaging-pipeline.yml [QNN EP] QNN SDK 2.28.2 (#22844) 2024-11-18 20:10:36 -08:00
qnn-ep-nuget-packaging-pipeline.yml [QNN EP] QNN SDK 2.28.2 (#22844) 2024-11-18 20:10:36 -08:00
rocm-nuget-packaging-pipeline.yml update pipline python version from 3.8 to 3.12 (#22517) 2024-10-21 07:50:31 -07:00
rocm-publish-nuget-pipeline.yml New rocm nuget publish pipeline (#22418) 2024-10-13 08:30:06 +08:00
web-ci-pipeline.yml Add a reminder in set-trigger-rules script (#21929) 2024-08-30 12:18:10 -07:00
win-ci-fuzz-testing.yml Update Node.js version from 18.x to 20.x in CI pipelines (#22576) 2024-10-24 07:34:42 -07:00
win-ci-pipeline.yml Remove training pipelines from Win CPI CI as redundant (#22190) 2024-09-23 18:15:41 -07:00
win-gpu-cuda-ci-pipeline.yml Revert DML pipeline changes (#23135) 2024-12-18 10:42:10 -08:00
win-gpu-dml-ci-pipeline.yml Revert DML pipeline changes (#23135) 2024-12-18 10:42:10 -08:00
win-gpu-doc-gen-ci-pipeline.yml Add a reminder in set-trigger-rules script (#21929) 2024-08-30 12:18:10 -07:00
win-gpu-reduce-op-ci-pipeline.yml Move jobs in onnxruntime-Win2022-GPU-T4 machine pool to onnxruntime-Win2022-GPU-A10 (#21023) 2024-06-12 22:04:40 -07:00
win-gpu-tensorrt-ci-pipeline.yml [TensorRT EP] Refactor TRT version update logic & apply TRT 10.5 (#22483) 2024-10-29 09:23:41 -07:00
win-gpu-training-ci-pipeline.yml Add a reminder in set-trigger-rules script (#21929) 2024-08-30 12:18:10 -07:00
win-gpu-webgpu-ci-pipeline.yml Fix delay load for WebGPU EP and DML EP (#23111) 2024-12-19 10:23:48 -08:00
win-qnn-arm64-ci-pipeline.yml [QNN EP] QNN SDK 2.28.2 (#22844) 2024-11-18 20:10:36 -08:00
win-qnn-ci-pipeline.yml [QNN EP] QNN SDK 2.28.2 (#22844) 2024-11-18 20:10:36 -08:00