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] Java API with oneDNN error: LoadLibrary failed with error 126 #18292

Open
PeipeiF opened this issue Nov 6, 2023 · 6 comments
Open

[Build] Java API with oneDNN error: LoadLibrary failed with error 126 #18292

PeipeiF opened this issue Nov 6, 2023 · 6 comments
Labels
api:Java issues related to the Java API build build issues; typically submitted using template ep:oneDNN questions/issues related to DNNL EP platform:windows issues related to the Windows platform stale issues that have not been addressed in a while; categorized by a bot

Comments

@PeipeiF
Copy link

PeipeiF commented Nov 6, 2023

Describe the issue

Hi,
I built ort Java jar with oneDNN EP and met error when executing my code. Error message shows that the onnxruntime_providers_dnnl.dll load failed with error code 126.
Error happens in this line:
options.addDnnl(true);
It seems that the onnxruntime_providers_dnnl.dll exists in the jar, but the program can't find it correctly. I'm not sure which step did I make a mistake when building.

Urgency

No response

Target platform

windows x64

Build script

.\build.bat --config Release --build_java --parallel --compile_no_warning_as_error --skip_submodule_sync --use_dnnl

Error / output

I got a ort jar with onnxruntime_providers_dnnl.dll, but error happens when options.addDnnl(true) is executed. The error message is as follows:

Exception in thread "main" ai.onnxruntime.OrtException: Error code - ORT_RUNTIME_EXCEPTION - message: C:\ProgramData\onnxruntime-1.16.1\onnxruntime\core\session\provider_bridge_ort.cc:1193 onnxruntime::ProviderLibrary::Get [ONNXRuntimeError] : 1 : FAIL : LoadLibrary failed with error 126 "" when trying to load "C:\Users\admin\AppData\Local\Temp\onnxruntime-java12664764697564321839\onnxruntime_providers_dnnl.dll"

Visual Studio Version

2022 community

GCC / Compiler Version

No response

@PeipeiF PeipeiF added the build build issues; typically submitted using template label Nov 6, 2023
@github-actions github-actions bot added api:Java issues related to the Java API ep:oneDNN questions/issues related to DNNL EP platform:windows issues related to the Windows platform labels Nov 6, 2023
@Craigacp
Copy link
Contributor

Craigacp commented Nov 7, 2023

It extracted the dll from the jar, but couldn't find the dependent libraries. I'm not sure what those are for DNNL on Windows.

@PeipeiF
Copy link
Author

PeipeiF commented Nov 15, 2023

It extracted the dll from the jar, but couldn't find the dependent libraries. I'm not sure what those are for DNNL on Windows.

It seems that the onnxruntime_providers_dnnl.dll were not extracted to the C:\Users\admin\AppData\Local\Temp\onnxruntime-java12664764697564321839\ directory. I'm not quite sure where the problem is.

@Craigacp
Copy link
Contributor

Craigacp commented Nov 15, 2023

The library is registered with a delete on exit hook. On Windows that doesn't usually fire due to the JVM shutdown code inside Windows only unloading the library after the hook has been called, but if library loading failed then it may well delete that library as it won't have been loaded. So try loading a model using the DNNL provider in something like jshell and checking the directory while the JVM is still running.

@PeipeiF
Copy link
Author

PeipeiF commented Nov 15, 2023

The library is registered with a delete on exit hook. On Windows that doesn't usually fire due to the JVM shutdown code inside Windows only unloading the library after the hook has been called, but if library loading failed then it may well delete that library as it won't have been loaded. So try loading a model using the DNNL provider in something like jshell and checking the directory while the JVM is still running.

Well, I found onnxruntime_providers_dnnl.dll when code was executed in jshell. However the library loading failure still remains unsolved. Do you have any suggestions to solve the problem?

@Craigacp
Copy link
Contributor

It's failing because the library loading path doesn't include something that DNNL requires. I don't know what that is, and on Windows it's a bit of a pain to find out because tools like ldd and otool aren't part of a default install. However if you compiled the ORT DNNL jar on your machine it must exist somewhere, just not on java.library.path or the default path lookup locations set as Windows environment variables. So however you told the cmake build that DNNL exists is what you need to add to the environment that the JVM is running in.

Copy link
Contributor

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 Dec 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api:Java issues related to the Java API build build issues; typically submitted using template ep:oneDNN questions/issues related to DNNL EP 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

2 participants