onnxruntime: onnxruntime/capi/onnxruntime_inference_collection.py", line 370, in _create_inference_session sess = C.InferenceSession(session_options, self._model_path, True, self._read_config_from_model) onnxruntime.capi.onnxruntime_pybind11_state.InvalidProtobuf: [ONNXRuntimeError] : 7 : INVALID_PROTOBUF : Load model from onnx_data/cpm_large_opt.onnx failed:Protobuf parsing failed.
onnxruntime/capi/onnxruntime_inference_collection.py", line 370, in _create_inference_session
sess = C.InferenceSession(session_options, self._model_path, True, self._read_config_from_model)
onnxruntime.capi.onnxruntime_pybind11_state.InvalidProtobuf: [ONNXRuntimeError] : 7 : INVALID_PROTOBUF : Load model from onnx_data/cpm_large_opt.onnx failed:Protobuf parsing failed.
A folder contains an very big ONNX model about 7 GB, with it’s onnx and external data. Onnxruntime not able to load this model back.
About this issue
- Original URL
- State: open
- Created 5 years ago
- Comments: 18 (5 by maintainers)
I also meet some problem, is there a solution, thanks ~
@snnn thanks. the onnx model is just 174kb. is that normal? the model is just exported via Pytorch, and I can using neuron visualize it and I can using onnx read the model successfully.
actually, what am doing, is using onnxruntime transformer optimization API to optimize this huge model. Seems it’s onnxruntime problem.
These kinds of errors occur when the model download url is not correct. In many of the instances it would be the metadata of the model downloaded as an
onnxfile. This can happen with models hosted on Git LFS.For example, in the case of huggingface models, it has three kind of URLs:
https://huggingface.co/memoavatar/memo/blob/main/misc/face_analysis/models/scrfd_10g_bnkps.onnx
https://huggingface.co/memoavatar/memo/raw/main/misc/face_analysis/models/scrfd_10g_bnkps.onnx
https://huggingface.co/memoavatar/memo/resolve/main/misc/face_analysis/models/scrfd_10g_bnkps.onnx
Since many of the repositories refer the model download path as https://huggingface.co/memoavatar/memo/raw/main/misc/face_analysis/models/scrfd_10g_bnkps.onnx rather than https://huggingface.co/memoavatar/memo/resolve/main/misc/face_analysis/models/scrfd_10g_bnkps.onnx, which ended up downloading that text file containing metadata as binary
onnxfile.So, the key is to ensure that model path is correct and is properly resolving the download url. In this case, fix is to replace
raw/mainwithresolve/mainin the model url.