【问题标题】:EntryPointNotFoundException: Unable to find an entry point named 'OrtGetApiBase' in DLL 'onnxruntime'EntryPointNotFoundException:无法在 DLL“onnxruntime”中找到名为“OrtGetApiBase”的入口点
【发布时间】:2021-10-04 12:06:03
【问题描述】:

我正在尝试在带有 VS 2019 的 Windows 10 Pro 上的 C# 4.8 框架中运行 sklearn onnx 模型,我在以下代码中使用了示例:

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/

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

我已经使用 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

当我运行这行代码时:

InferenceSession session = new InferenceSession(modelPath);

我收到此错误:

System.TypeInitializationException: 'Microsoft.ML.OnnxRuntime.NativeMethods' 的类型初始化程序引发了异常。'

EntryPointNotFoundException:无法在 DLL“onnxruntime”中找到名为“OrtGetApiBase”的入口点。

在:

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

【问题讨论】:

    标签: c# onnx onnxruntime


    【解决方案1】:

    同样的问题应该已经在这里解决了:https://github.com/microsoft/onnxruntime/issues/9260

    简而言之,需要将包(onnxruntime.dll)加载到启动项目中才能使用OrtGetApiBase。

    【讨论】:

    • 对于我在启动项目中使用 onnxruntime 的 ASP.NET 5 项目仍然不起作用。尝试了我在网上可以找到的所有内容。
    • 通过查找本机运行时 DLL 并手动复制到应用程序的目录来部分修复。
    猜你喜欢
    • 2011-04-14
    • 1970-01-01
    • 1970-01-01
    • 2021-08-05
    • 2017-08-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多