System.Runtime.InteropServices.SEHException when loading ONNX models
Can someone help me with ONNX estimator.
System information
- OS version/distro: Windows 10 Version 1709 Build 16299.726
- .NET Version (eg., dotnet --info): .NET core 2.1
Issue
- What did you do? Followed the tests and tried to load an existing Onnx model(squeezenet)using estimator (tried both static and dynamic)
- **What happened? System.Runtime.InteropServices.SEHException: 'External component has thrown an exception
- What did you expect? To load the onnx model and predict using it
Source code / logs
Please paste or attach the code or logs or traces that would be helpful to diagnose the issue you are reporting. OnnxApp.zip
@AarthyKS Your model is not placed in the correct location. You need to either place it where the executable is run from (inside bin\x64\Debug\netcoreapp2.1), modify your model path to reflect this, or use an absolute path.
@jignparm @shmoradims It seems like the ONNX estimator not finding the model should really give a better/more descriptive error message? Also for some reason, the checks inside the estimator itself don't seem to always catch this, and it propagates down to the ModelManager inside the Sonoma code.
@AarthyKS , try a fully qualified path to the model file, instead of a relative path below. Also, make sure there's only 1 onnx model file in the directory (this restriction will go away shortly after we transition to the new runtime librrary).
if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
return;
var modelFile = "sq_model.onnx";
using (var env = new ConsoleEnvironment(null, false, 0, 1, null, null))
{
var imageHeight = 224;
var imageWidth = 224;
@vaeksare - this upcoming release of the library will return back better error messages. The current SEH exception is too generic to debug anything with..
@vaeksare @jignparm : Still hitting the same exception " System.Runtime.InteropServices.SEHException when loading ONNX models"
As suggested I've made the following changes
-
I've placed the model file is where the executable is run from (inside bin\x64\Debug\netcoreapp2.1)
-
using absolute path for model location
-
Also there is only one model file in the bin folder.
if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
return;
string path = System.Reflection.Assembly.GetExecutingAssembly().Location;
var modelFile = Path.GetDirectoryName(path) + "\\sq_model.onnx";
The underlying Microsoft.ML.Scoring library doesn't propagate messages from the native layer (to be fixed soon).
This is the error message using an updated version of the library (to be released soon)-- it looks like there's no suitable kernel definition for the RELU op. What is the source of your model? Did you convert using MLTools, or some other method?
The model was not created using MLtools. The model is from ONNX model zoo . It is mentioned that it was created in Caffe2.
Onnx is not backwards compatible to 1.1 as far as I understand. The version of Onnx models supported by the transform is 1.2.
The squeezenet model from the model zoo below works without any problems.
https://s3.amazonaws.com/download.onnx/models/opset_7/squeezenet.tar.gz
Marking this as resolved. Reopen if necessary.