Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Build] Is it possible to build onnxruntime with DirectML EP statically? #17774

Open
xeeetu opened this issue Oct 3, 2023 · 5 comments
Open
Labels
build build issues; typically submitted using template ep:DML issues related to the DirectML execution provider platform:windows issues related to the Windows platform stale issues that have not been addressed in a while; categorized by a bot

Comments

@xeeetu
Copy link

xeeetu commented Oct 3, 2023

Describe the issue

Urgency

As soon as possible, the project is under development.

Target platform

Windows

Build script

./build.bat --config Release --parallel --enable_msvc_static_runtime --use_dml (I used this command to build, I attach a file with test results. There were no errors when building a single onnxruntime.)

Error / output

tests.txt

Visual Studio Version

2022

GCC / Compiler Version

No response

@xeeetu xeeetu added the build build issues; typically submitted using template label Oct 3, 2023
@github-actions github-actions bot added ep:DML issues related to the DirectML execution provider platform:windows issues related to the Windows platform labels Oct 3, 2023
@wschin
Copy link
Contributor

wschin commented Oct 3, 2023

Your build log looks ok -- it finished the build but failed one post-build test.

1: D:\onnxruntime\onnxruntime\test\providers\checkers.cc(265): error: The difference between cur_expected[i] and cur_actual[i] is inf, where
1: cur_expected[i] evaluates to 3.4028234663852886e+38,
1: cur_actual[i] evaluates to inf.
1: The abs_error parameter threshold evaluates to 0.004999999888241291 which is smaller than the minimum distance between doubles for numbers of this magnitude which is 3.7778931862957162e+22, thus making this EXPECT_NEAR check equivalent to EXPECT_EQUAL. Consider using EXPECT_DOUBLE_EQ instead.
1: i:10
1: Google Test trace:
1: D:\onnxruntime\onnxruntime\test\providers\checkers.cc(484): provider type: DmlExecutionProvider
1: D:\onnxruntime\onnxruntime\test\providers\base_tester.cc(774): registered execution providers: DmlExecutionProvider
1: [  FAILED  ] ActivationOpTest.Gelu (656 ms)

Since this kind of error is usually reasonable, I'd ignore it for now. Do you see other problems during the build?

@wschin
Copy link
Contributor

wschin commented Oct 3, 2023

I am not sure. Maybe you can find answer in the section of building DirectML execution provider at

target_link_libraries(${target} PRIVATE DirectML)
. It allows custom build of DirectML, so it's possible you can statically link to DirectML if you build DirectML from source or the installed DirectML has a static library.

onnxruntime/build\Windows\packages\Microsoft.AI.DirectML.1.12.1 looks like a third-party library --- If you want to statically link against DirectML, you need to make sure it includes a DirectML.lib for static linking. I am not sure if DirectML has that DirectML.lib.

@fdwr
Copy link
Contributor

fdwr commented Oct 4, 2023

xeetu: So there's the:

  • "DML EP" (DirectML execution provider) which is built as part of ONNX Runtime and translates ONNX operators to DirectML.dll calls.
  • DirectML.dll which is a separate library holds the necessary logic to run D3D shaders on the GPU, available via Nuget in redistributable form and as an older system version in Windows/System32 (but ORT uses the newer redist versions). https://www.nuget.org/packages/Microsoft.AI.DirectML
  • DirectML.lib here just is the import library just to call DMLCreateDevice and doesn't contain DML code.

Like Wei-Sheng said, I'm not seeing any actual build errors, just a test failure that's not unreasonably far away. If you run with --skip_tests, does the build complete?

@wschin
Copy link
Contributor

wschin commented Oct 4, 2023

I guess you just need to use DirectML.dll as a DLL for building onnxruntime. If you want to execute onnxruntime on another machine, just install DirectML nuget on that machine.

Copy link
Contributor

github-actions bot commented Nov 4, 2023

This issue has been automatically marked as stale due to inactivity and will be closed in 7 days if no further activity occurs. If further support is needed, please provide an update and/or more details.

@github-actions github-actions bot added the stale issues that have not been addressed in a while; categorized by a bot label Nov 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build build issues; typically submitted using template ep:DML issues related to the DirectML execution provider platform:windows issues related to the Windows platform stale issues that have not been addressed in a while; categorized by a bot
Projects
None yet
Development

No branches or pull requests

3 participants