microsoft / onnxruntime

ONNX Runtime: cross-platform, high performance ML inferencing and training accelerator
https://onnxruntime.ai
MIT License
14.12k stars 2.84k forks source link

ONNX Runtime DLL load Error #10290

Open rishabhmalhotra027 opened 2 years ago

rishabhmalhotra027 commented 2 years ago

While using onnxruntime reference in a net framework project, we are hitting the following exception in production

Unexpected error encountered by 'Alexandria' processor: System.TypeInitializationException: The type initializer for 'Microsoft.Substrate.KnowledgeMining.DefinitionExtraction.PreProcessingHelperFactory' threw an exception. ---> System.TypeInitializationException: The type initializer for 'Microsoft.ML.OnnxRuntime.NativeMethods' threw an exception. ---> System.DllNotFoundException: Unable to load DLL 'onnxruntime': The specified module could not be found. (Exception from HRESULT: 0x8007007E) at Microsoft.ML.OnnxRuntime.NativeMethods.OrtGetApiBase() at Microsoft.ML.OnnxRuntime.NativeMethods..cctor() --- End of inner exception stack trace --- at Microsoft.ML.OnnxRuntime.SessionOptions..ctor() at Microsoft.Substrate.KnowledgeMining.DefinitionExtraction.PreProcessingHelperFactory..cctor() --- End of inner exception stack trace --- at Microsoft.Substrate.KnowledgeMining.DefinitionExtraction.PreProcessingHelperFactory.GetLanguageWordEmbedding(String language) at Microsoft.Substrate.KnowledgeMining.DefinitionExtraction.MultilingualPreProcessor.GetClassificationIndex(String sentence, String language, ILogger logger, IMetricsLogger metricsLogger) at Microsoft.Substrate.KnowledgeMining.DefinitionExtraction.SpanishSpecificTextProcessor.GetFilteredSentences(IList1 sentences) at Microsoft.Substrate.KnowledgeMining.DefinitionExtraction.DefinitionsExtractor.ExtractAndFilterSentencesMultilingual(ILogger logger, IMetricsLogger metricsLogger, String body, DefinitionSettings definitionSettings, Guid tenantId, Boolean isPreFilteringEnabled) at Microsoft.Substrate.KnowledgeMining.DefinitionExtraction.DefinitionsExtractor.<ExtractDefinitionsMultilingual>d__23.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.Substrate.KnowledgeMining.DefinitionExtraction.DefinitionsExtractor.<ExtractDefinitions>d__21.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.Griffin.SharePointHome.Notifier.KnowledgeGraph.Processors.Extractors.DefinitionsMultiTypeExtractor.<ExtractAsync>d__6.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.Griffin.KnowledgeGraph.Processors.ProcessingSteps.DefinitionExtractionStep.<ExecuteAsync>d__6.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at Microsoft.Griffin.KnowledgeGraph.Processors.MultiStepProcessor1.<ExecuteAsync>d__6.MoveNext()

We cannot reproduce the same error in local machine, as the dll reference is present in the project, and we're able to see the dll in the target folder once we build the project.

Here are the references in the dev csproj <Reference Include="Microsoft.ML.OnnxRuntime"> <HintPath>$(PkgMicrosoft_ML_OnnxRuntime_Managed_1_4_0)\lib\netstandard1.1\Microsoft.ML.OnnxRuntime.dll</HintPath> </Reference> <Reference Include="netstandard" /> <Reference Include="System" /> <Reference Include="System.Memory"> <HintPath>$(PkgSystem_Memory)\lib\netstandard2.0\System.Memory.dll</HintPath> </Reference>

<ItemGroup> <Content Include="$(PkgMicrosoft_ML_OnnxRuntime_1_4_0)\runtimes\win-x64\native\onnxruntime.dll" Visible="false"> <Link>onnxruntime.dll</Link> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> </Content> <Content Include="$(PkgMicrosoft_ML_OnnxRuntime_1_4_0)\runtimes\win-x64\native\onnxruntime.lib" Visible="false"> <Link>onnxruntime.lib</Link> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> </Content> </ItemGroup>

The same references had to be mentioned in the test csproj, otherwise the unit tests were hitting an error - Unable to find an entry point named ‘OrtGetApiBase’ in DLL ‘onnxruntime’ in local, and the same exception as above in cloud build. Do we need to add something else in the csproj to make this work in prod?

System information

tianleiwu commented 2 years ago

Some dependent DLLs are needed. You can use Dependency Walker (depends.exe) tool to see extra DLLs needed.

stale[bot] commented 2 years ago

This issue has been automatically marked as stale due to inactivity and will be closed in 7 days if no further activity occurs. If further support is needed, please provide an update and/or more details.