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.
image

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)

Most upvoted comments

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.

image image

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 onnx file. This can happen with models hosted on Git LFS.

For example, in the case of huggingface models, it has three kind of URLs:

  1. https://huggingface.co/memoavatar/memo/blob/main/misc/face_analysis/models/scrfd_10g_bnkps.onnx

    • This shows the web version of the model on their portal
  2. https://huggingface.co/memoavatar/memo/raw/main/misc/face_analysis/models/scrfd_10g_bnkps.onnx

    • This shows the raw pointer file of the model which represents the metadata of the model, something like
        version https://git-lfs.github.com/spec/v1
        oid sha256:5838f7fe053675b1c7a08b633df49e7af5495cee0493c7dcf6697200b85b5b91
        size 16923827
    
  3. https://huggingface.co/memoavatar/memo/resolve/main/misc/face_analysis/models/scrfd_10g_bnkps.onnx

    • This resolve the download url of the file and downloads the model.

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 onnx file.

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/main with resolve/main in the model url.