azuric
azuric

Reputation: 2839

EntryPointNotFoundException: Unable to find an entry point named 'OrtGetApiBase' in DLL 'onnxruntime'

I am trying to run an sklearn onnx model in C# 4.8 framework on Windows 10 Pro with VS 2019, I have used the following code using examples in:

https://towardsdatascience.com/deploy-sci-kit-learn-models-in-net-core-applications-90e24e572f64

https://vkontech.com/making-predictions-in-c-with-a-pre-trained-tensorflow-model-via-onnx/

and

https://learn.microsoft.com/en-us/azure/machine-learning/how-to-use-automl-onnx-model-dotnet

I have imported using nuget

Install-Package Microsoft.ML.OnnxRuntime -Version 1.9.0
Install-Package Microsoft.ML.OnnxRuntime.Gpu -Version 1.9.0
Install-Package Microsoft.ML.OnnxTransformer -Version 1.6.0
Install-Package Microsoft.ML.OnnxRuntime.MKLML -Version 1.6.0
Install-Package Microsoft.ML -Version 1.5.5

when i run this line of code:

InferenceSession session = new InferenceSession(modelPath);

I receive this error:

System.TypeInitializationException: 'The type initializer for 'Microsoft.ML.OnnxRuntime.NativeMethods' threw an exception.'

EntryPointNotFoundException: Unable to find an entry point named 'OrtGetApiBase' in DLL 'onnxruntime'.

in:

public SessionOptions()
    : base(IntPtr.Zero, true)
{
    NativeApiStatus.VerifySuccess(NativeMethods.OrtCreateSessionOptions(out handle));
}

Upvotes: 3

Views: 7714

Answers (2)

Thomas Weller
Thomas Weller

Reputation: 59420

I got this error message when using the Nuget package

Microsoft.ML.OnnxRuntime.Managed

without the required native libraries of the Nuget package

Microsoft.ML.OnnxRuntime

The managed version does not install the native libraries as a dependency.

Upvotes: 1

Chun-Wei Chen
Chun-Wei Chen

Reputation: 54

Same issue should already be resolved here: https://github.com/microsoft/onnxruntime/issues/9260

In short, you need to load the package (onnxruntime.dll) into the startup project to use OrtGetApiBase.

Upvotes: 3

Related Questions