Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Onnxruntime not working properly for netfx #2106

Closed
Anipik opened this issue Jan 10, 2019 · 6 comments
Closed

Onnxruntime not working properly for netfx #2106

Anipik opened this issue Jan 10, 2019 · 6 comments
Assignees
Labels
bug Something isn't working
Projects
Milestone

Comments

@Anipik
Copy link
Contributor

Anipik commented Jan 10, 2019

I am trying to run the test SimpleEndToEndOnnxConversionTest on netfx

I get this is as an error

[xUnit.net 00:00:08.31]     Microsoft.ML.Tests.OnnxConversionTest.SimpleEndToEndOnnxConversionTest [FAIL]
Failed   Microsoft.ML.Tests.OnnxConversionTest.SimpleEndToEndOnnxConversionTest
Error Message:
 System.DllNotFoundException : Unable to load DLL 'onnxruntime.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)
Stack Trace:
   at Microsoft.ML.OnnxRuntime.NativeMethods.OrtCreateSessionOptions()
   at Microsoft.ML.OnnxRuntime.SessionOptions..ctor()
   at Microsoft.ML.OnnxRuntime.SessionOptions.MakeSessionOptionWithMklDnnProvider()
   at System.Lazy`1.CreateValue()
   at System.Lazy`1.LazyInitValue()
   at Microsoft.ML.OnnxRuntime.InferenceSession..ctor(String modelPath)
   at Microsoft.ML.Transforms.OnnxModel..ctor(String modelFile, Nullable`1 gpuDeviceId, Boolean fallbackToCpu) in C:\git\machinelearning\src\Microsoft.ML.OnnxTransform\OnnxUtils.cs:line 101
   at Microsoft.ML.Transforms.OnnxTransform..ctor(IHostEnvironment env, Arguments args, Byte[] modelBytes) in C:\git\machinelearning\src\Microsoft.ML.OnnxTransform\OnnxTransform.cs:line 190
   at Microsoft.ML.Transforms.OnnxTransform..ctor(IHostEnvironment env, String modelFile, String[] inputColumns, String[] outputColumns, Nullable`1 gpuDeviceId, Boolean fallbackToCpu) in C:\git\machinelearning\src\Microsoft.ML.OnnxTransform\OnnxTransform.cs:line 273
   at Microsoft.ML.Transforms.OnnxScoringEstimator..ctor(IHostEnvironment env, String modelFile, String[] inputColumns, String[] outputColumns, Nullable`1 gpuDeviceId, Boolean fallbackToCpu) in C:\git\machinelearning\src\Microsoft.ML.OnnxTransform\OnnxTransform.cs:line 560
   at Microsoft.ML.Tests.OnnxConversionTest.SimpleEndToEndOnnxConversionTest() in C:\git\machinelearning\test\Microsoft.ML.Tests\OnnxConversionTest.cs:line 74

Although I looked at the output folder, I saw there was a dll named as Microsost.ML.OnnxRuntime.dll(not sure if it is similar to onnxruntime.dll)
I renamed it to onnxruntime.dll, and then I was getting

[xUnit.net 00:00:07.41]     Microsoft.ML.Tests.OnnxConversionTest.SimpleEndToEndOnnxConversionTest [FAIL]
Failed   Microsoft.ML.Tests.OnnxConversionTest.SimpleEndToEndOnnxConversionTest
Error Message:
 System.EntryPointNotFoundException : Unable to find an entry point named 'OrtCreateSessionOptions' in DLL 'onnxruntime.dll'.
Stack Trace:
   at Microsoft.ML.OnnxRuntime.NativeMethods.OrtCreateSessionOptions()
   at Microsoft.ML.OnnxRuntime.SessionOptions..ctor()
   at Microsoft.ML.OnnxRuntime.SessionOptions.MakeSessionOptionWithMklDnnProvider()
   at System.Lazy`1.CreateValue()
   at System.Lazy`1.LazyInitValue()
   at Microsoft.ML.OnnxRuntime.InferenceSession..ctor(String modelPath)
   at Microsoft.ML.Transforms.OnnxModel..ctor(String modelFile, Nullable`1 gpuDeviceId, Boolean fallbackToCpu) in C:\git\machinelearning\src\Microsoft.ML.OnnxTransform\OnnxUtils.cs:line 101
   at Microsoft.ML.Transforms.OnnxTransform..ctor(IHostEnvironment env, Arguments args, Byte[] modelBytes) in C:\git\machinelearning\src\Microsoft.ML.OnnxTransform\OnnxTransform.cs:line 190
   at Microsoft.ML.Transforms.OnnxTransform..ctor(IHostEnvironment env, String modelFile, String[] inputColumns, String[] outputColumns, Nullable`1 gpuDeviceId, Boolean fallbackToCpu) in C:\git\machinelearning\src\Microsoft.ML.OnnxTransform\OnnxTransform.cs:line 273
   at Microsoft.ML.Transforms.OnnxScoringEstimator..ctor(IHostEnvironment env, String modelFile, String[] inputColumns, String[] outputColumns, Nullable`1 gpuDeviceId, Boolean fallbackToCpu) in C:\git\machinelearning\src\Microsoft.ML.OnnxTransform\OnnxTransform.cs:line 560
   at Microsoft.ML.Tests.OnnxConversionTest.SimpleEndToEndOnnxConversionTest() in C:\git\machinelearning\test\Microsoft.ML.Tests\OnnxConversionTest.cs:line 74

@eerhardt @danmosemsft @shauheen @TomFinley @jignparm

@shauheen shauheen added the bug Something isn't working label Jan 10, 2019
@shauheen
Copy link
Contributor

@jignparm can you please take a look.

@shauheen shauheen added this to To Do in v0.10 Jan 10, 2019
@shauheen shauheen added this to the 0119 milestone Jan 10, 2019
@jignparm
Copy link
Contributor

jignparm commented Jan 13, 2019

Microsost.ML.OnnxRuntime.dll is not the same as onnxruntime.dll. The first contains the .Net managed code whereas the second contains the native code, and is contained within the runtimes folder in the nuget. What version of .NetFramework are you using (4.6.1 or other?)

@eerhardt, the it seems like the properties file below does not copy the 'onnxruntime.dll' native file to the output folder. Does this need to be updated to work with different versions of .NetFramework? This pattern is being used for other projects (e.g. TensorFlow, and MatrixFactorization).

https://github.com/Microsoft/onnxruntime/blob/master/csharp/src/Microsoft.ML.OnnxRuntime/Microsoft.ML.OnnxRuntime.props

@Anipik
Copy link
Contributor Author

Anipik commented Jan 13, 2019

What version of .NetFramework are you using (4.6.1 or other?)

The version is 4.6.2

@eerhardt
Copy link
Member

That .props file is only there to support when a project is using packages.config. See:

  <ItemGroup Condition="Exists('packages.config') OR
                        Exists('$(MSBuildProjectName).packages.config') OR
                        Exists('packages.$(MSBuildProjectName).config')">

We are using PackageReference in our .csproj, so this code doesn't kick in (by design). Instead, NuGet will automatically include the runtimes\RID\native files, if the RID is set correctly.

It appears that the RIDs are not lining up correctly. In our ML.NET tests we are using win-x64 (i.e. any Windows x64 based machine):

https://github.com/dotnet/machinelearning/blob/master/test/Directory.Build.props#L9

But in the OnnxRuntime package, it is using win10-x64 (i.e. Windows 10 x64 based machines). Thus, the tests aren't picking up these native assets because the test is saying it should run on any Windows machine. While these native assets say they only work on Windows 10.

I've had conversations with @shahasad in the past on whether the OnnxRuntime package should change to use the win-x64 RID. If it packaged the native assets in that folder, this would start working.

@jignparm
Copy link
Contributor

Fix added to Onnxruntime to update to Win-x64. Will be available in next release of the Nuget.

https://github.com/Microsoft/onnxruntime/blob/139abda393d8410e1c35469adfcc7d13d109a997/csharp/src/Microsoft.ML.OnnxRuntime/Microsoft.ML.OnnxRuntime.csproj#L47

@jignparm
Copy link
Contributor

Resolved via #2085

v0.10 automation moved this from To Do to Done Jan 31, 2019
@ghost ghost locked as resolved and limited conversation to collaborators Mar 25, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
No open projects
v0.10
  
Done
Development

No branches or pull requests

4 participants