繁体   English   中英

无法加载 DLL 'onnxruntime' 或其依赖项之一 ML.NET

[英]Unable to load DLL 'onnxruntime' or one of its dependencies ML.NET

我从 Python 得到这个 onnx,但我在 context.Transforms.ApplyOnnxModel() 中收到错误 - “无法加载 DLL 'onnxruntime' 或其一个问题依赖项:找不到指定的模块。(0x800700)我应该改变吗?

在此处输入图像描述

错误

'context.Transforms.ApplyOnnxModel(modelPath)' threw an exception of type 'System.TypeInitializationException'
    Data: {System.Collections.ListDictionaryInternal}
    HResult: -2146233036
    HelpLink: null
    InnerException: {"Unable to load DLL 'onnxruntime' or one of its dependencies: The specified module could not be found. (0x8007007E)"}
    Message: "The type initializer for 'Microsoft.ML.OnnxRuntime.NativeMethods' threw an exception."
    Source: "Microsoft.ML.OnnxRuntime"
    StackTrace: "   at Microsoft.ML.OnnxRuntime.SessionOptions..ctor()\r\n   at Microsoft.ML.OnnxRuntime.InferenceSession..ctor(String modelPath)\r\n   at Microsoft.ML.Transforms.Onnx.OnnxModel..ctor(String modelFile, Nullable`1 gpuDeviceId, Boolean fallbackToCpu, Boolean ownModelFile, IDictionary`2 shapeDictionary)\r\n   at Microsoft.ML.Transforms.Onnx.OnnxTransformer..ctor(IHostEnvironment env, Options options, Byte[] modelBytes)\r\n   at Microsoft.ML.Transforms.Onnx.OnnxTransformer..ctor(IHostEnvironment env, String[] outputColumnNames, String[] inputColumnNames, String modelFile, Nullable`1 gpuDeviceId, Boolean fallbackToCpu, IDictionary`2 shapeDictionary)\r\n   at Microsoft.ML.Transforms.Onnx.OnnxScoringEstimator..ctor(IHostEnvironment env, String modelFile, Nullable`1 gpuDeviceId, Boolean fallbackToCpu, IDictionary`2 shapeDictionary)\r\n   at Microsoft.ML.OnnxCatalog.ApplyOnnxModel(TransformsCatalog catalog, String modelFile, Nullable`1 gpuDeviceId, Boolean fallbackToCpu)"
    TargetSite: {Void .ctor()}
    TypeName: "Microsoft.ML.OnnxRuntime.NativeMethods"

我在错误的教程之前使用了这项工作正确https://docs.microsoft.com/en-us/azure/machine-learning/how-to-use-automl-onnx-model-dotnet

添加参数输入和 output

var onnxPredictionPipeline =
    mlContext
        .Transforms
        .ApplyOnnxModel(
            outputColumnNames: outputColumns,
            inputColumnNames: inputColumns,
            ONNX_MODEL_PATH);

和正确的包裹

dotnet add package Microsoft.ML
dotnet add package Microsoft.ML.OnnxRuntime
dotnet add package Microsoft.ML.OnnxTransformer

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM