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

0

I get this onnx from Python but I received error in context.Transforms.ApplyOnnxModel() - "Unable to load DLL 'onnxruntime' or one of its dependencies: The specified module could not be found. (0x8007007E) where is a problem? What should I change?

enter image description here

error

'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"
c#
ml.net

1 Answer

0

I used before wrong tutorial this work correct https://docs.microsoft.com/en-us/azure/machine-learning/how-to-use-automl-onnx-model-dotnet

added parameters input and output

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

and correct packages

dotnet add package Microsoft.ML
dotnet add package Microsoft.ML.OnnxRuntime
dotnet add package Microsoft.ML.OnnxTransformer
answered on Stack Overflow Dec 16, 2020 by Rafał Developer • edited Dec 16, 2020 by Rafał Developer

User contributions licensed under CC BY-SA 3.0