Testing ONNX model for super resolution model, I have error running this sample program.
My ONNX version is 1.5.0 with onnxruntime 1.4.0. Onnxruntime was installed using pip. Pytorch version is 1.6.0
Error is at ort_session = onnxruntime.InferenceSession('/home/itc/pytorch/sub_pixel_cnn_2016/model/super-resolution-10.onnx')
The error is in loading onnx model.
Traceback (most recent call last):
File "test.py", line 73, in <module>
ort_session = onnxruntime.InferenceSession('/home/itc/pytorch/sub_pixel_cnn_2016/model/super-resolution-10.onnx')
File "/home/itc/pytorch/lib/python3.7/site-packages/onnxruntime/capi/session.py", line 158, in __init__
self._load_model(providers or [])
File "/home/itc/pytorch/lib/python3.7/site-packages/onnxruntime/capi/session.py", line 166, in _load_model
True)
RuntimeError: /onnxruntime_src/onnxruntime/core/session/inference_session.cc:238 onnxruntime::InferenceSession::InferenceSession(const onnxruntime::SessionOptions&, const onnxruntime::Environment&, const string&) status.IsOK() was false. Given model could not be parsed while creating inference session. Error message: Protobuf parsing failed.
How can I solve the error?
super-resolution-10.onnx
seems to load OK for me. I downloaded the file from https://github.com/onnx/models/blob/master/vision/super_resolution/sub_pixel_cnn_2016/model/super-resolution-10.onnxI also tried
pip install onnxruntime==1.4.0
- also works fine.Then tried to load it (there are bunch of warnings, but it loads ok):
I think it's likely your ONNX file is corrupted, please try to load it with Netron to verify.
As a side note, PyTorch version and onnx version should be irrelevant for the loading.