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

Issue finding onnxruntime dll #15375

Closed
oliver-bernhardt opened this issue Apr 5, 2023 · 13 comments
Closed

Issue finding onnxruntime dll #15375

oliver-bernhardt opened this issue Apr 5, 2023 · 13 comments
Labels
platform:windows issues related to the Windows platform

Comments

@oliver-bernhardt
Copy link

Describe the issue

Hi

We are facing an issue with onnxruntime in our C# application. Usually, everything works just fine on any type of Windows 10 x64 platform. However for some reason (that is not clear to me) we get this exception

The type initializer for 'Microsoft.ML.OnnxRuntime.NativeMethods' threw an exception.
System.EntryPointNotFoundException: Unable to find an entry point named 'OrtGetApiBase' in DLL 'onnxruntime'.

on this system:

Edition Windows 10 Enterprise LTSC
Version 21H2
Installed on ‎24/‎03/‎2023
OS build 19044.2728
Experience Windows Feature Experience Pack 120.2212.4190.0
Processor Intel(R) Xeon(R) W-2295 CPU @ 3.00GHz 3.00 GHz
Installed RAM 128 GB (128 GB usable)
System type 64-bit operating system, x64-based processor

By default, the ddls are stored in the subfolder "bin\runtimes\win-x86" and "bin\runtimes\win-x64".
I also tried moving them into the same folder as the main executable without any change.

I need to point out that this was never a problem on Windows 10 Professional so I wonder whether you know anything to be special in this environment?

Is there anything else that could cause this issue? Any idea on how I could further investigate the problem?

Oli

To reproduce

I currently don't know whether it is reproducible as I only have 1 system with this setup on which it does happen.

Urgency

No response

Platform

Windows

OS Version

Windows 10 Enterprise LTSC, Version 21H2, 19044.2728

ONNX Runtime Installation

Released Package

ONNX Runtime Version or Commit ID

1.12.1

ONNX Runtime API

C#

Architecture

X64

Execution Provider

Default CPU

Execution Provider Library Version

No response

@github-actions github-actions bot added the platform:windows issues related to the Windows platform label Apr 5, 2023
@baijumeswani
Copy link
Contributor

I found a similar issue reported earlier and saw some solutions posted by users: #9260.

Were you able to try those out? Let me know if any of those worked for you.

@oliver-bernhardt
Copy link
Author

Hey

Thanks for pointing it out. However, I don't think this is the same issue. In our case, it works pretty much every (hundreds of installations on Windows 10 without any issue). But somehow, on that particular system it does not work (same build of the software using the same installer and everything).

I will try the solution that was provided in that thread but I doubt it will change anything. It will take a while till I know for sure as I have to indirectly troubleshoot it as I can not reproduce the problem (it's a user that reported the issue on his machine).

Oli

@oliver-bernhardt
Copy link
Author

Unfortunately, the suggested solution did not change anything.

I found this statement on the ONNX project page regarding en_US.UTF-8. Is this relevant for Windows 10? How can I check whether that is correctly installed.

image

Regarding the other dependency (Visual C++ 2019 runtime) we already provide that with our software so that should be good.

@snnn
Copy link
Member

snnn commented Apr 11, 2023

In our case, it works pretty much every (hundreds of installations on Windows 10 without any issue). But somehow, on that particular system it does not work (same build of the software using the same installer and everything).

Do all the Win10 have the same OS version? You can run "winver" command to check.

@baijumeswani
Copy link
Contributor

@oliver-bernhardt would you please share with us the logs you're seeing for the dlls being loaded. You will need to put your program into a debugger to get those logs.

Please see @snnn's comment for an example on how to do this.

@ihtfw
Copy link

ihtfw commented Apr 20, 2023

I faced same problem for net472 and problem was that onnxruntime.dll wasn't copied to output. To fix this I had to specify runtime identifier explicitly like this in exe csproj:

  <PropertyGroup>
    <RuntimeIdentifier>win-x64</RuntimeIdentifier>
    <AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath>
  </PropertyGroup>

@jamesd-ms
Copy link

Hello, seeing similar exception in the released v1.15.0 https://www.nuget.org/packages/Microsoft.ML.OnnxRuntime/1.15.0

System.TypeInitializationException: The type initializer for 'Microsoft.ML.OnnxRuntime.NativeMethods' threw an exception. ---> System.DllNotFoundException: Unable to load DLL 'onnxruntime' or one of its dependencies: The specified procedure could not be found. (0x8007007F)
at Microsoft.ML.OnnxRuntime.NativeMethods.OrtGetApiBase()
at Microsoft.ML.OnnxRuntime.NativeMethods..cctor()

No such error previously when using older version; even a v1.15.0-dev version is working fine.

@yuslepukhin
Copy link
Member

Check how many onnxruntime.dlls you have on the system and see which one is being loaded. Quick check is to open a command line and do where onnxruntime.dll and see which one shows up.

Check this.

@skottmckay
Copy link
Contributor

@jamesd-ms can you provide a minimal sln and csproj that repros the issue? AFAIK nothing changed in the structure of the native nuget package recently that would change where it looks for onnxruntime.dll.

For most .net targets I would expect it's using the netstandard2.0 (lowest common denominator for the ORT native package) props. e.g. for x64 that would mean linking onnxruntime.dll from runtimes\win-x64\native in the nuget package.

image

@skottmckay
Copy link
Contributor

@jamesd-ms which dev build of the package was working? can diff that vs. the release to see what changed

skottmckay added a commit that referenced this issue Jun 9, 2023
### Description
<!-- Describe your changes. -->
SetThreadDescription isn't available in an Azure App Service sandbox.
#15219 removed a check that it was available, making it a hard
dependency. When it's not available the dll load fails with a 'procedure
not found' error.

Add back the check.

### Motivation and Context
<!-- - Why is this change required? What problem does it solve?
- If it fixes an open issue, please link to the issue here. -->

#15375 - although note this has nothing to do with the original issue.
This is just for
#15375 (comment)
snnn pushed a commit that referenced this issue Jun 15, 2023
### Description
<!-- Describe your changes. -->
SetThreadDescription isn't available in an Azure App Service sandbox.
#15219 removed a check that it was available, making it a hard
dependency. When it's not available the dll load fails with a 'procedure
not found' error.

Add back the check.

### Motivation and Context
<!-- - Why is this change required? What problem does it solve?
- If it fixes an open issue, please link to the issue here. -->

#15375 - although note this has nothing to do with the original issue.
This is just for
#15375 (comment)
@snnn
Copy link
Member

snnn commented Jun 17, 2023

In ONNX Runtime 1.15.1 release we fixed an issue that could cause such problems in some Sandbox environments, however, the fix was not for the original issue reported here.

@snnn
Copy link
Member

snnn commented Jul 27, 2023

ONNX Runtime 1.15.1 is published.

@ErrorGz
Copy link

ErrorGz commented Oct 13, 2023

After compiling a program that uses onnxruntime, it runs fine on my local machine and also runs smoothly in common runtime environments. However, when I installed Windows 10 or Windows 11, the program failed to run. To resolve this, I installed some toolkits for vs2022 in the new system environment, and now the program runs properly. The toolkits I installed for your reference include:

Microsoft Visual C++ Redistributable
.NET 6.0 Runtime (Long-Term Support)
.NET Profiler
C++ Core Features
MSVC v143 - VS 2022 C++ x64/x86 Build Tools
Graphics Debugger and GPU Profiler for DirectX
C++ Profiler
Please note that the above information and translations may not perfectly match the original English version, as I used a Simplified Chinese environment for installation and gathering information.

Finally, I determined that the missing tool in the new operating system is the .NET Profiler.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
platform:windows issues related to the Windows platform
Projects
None yet
Development

No branches or pull requests

8 participants