onnx / tutorials

Tutorials for creating and using ONNX models
Apache License 2.0
3.35k stars 627 forks source link

Update onnx_graph_to_caffe2_net call #80

Open dllehr81 opened 5 years ago

dllehr81 commented 5 years ago

The tutorial CorrectnessVerificationAndPerformanceComparison.ipynb has an old call to Caffe2Backend.onnx_graph_to_caffe2_net which references onnx_model.graph instead of just the model onnx_model
Resulting in the error

    init_net, predict_net = Caffe2Backend.onnx_graph_to_caffe2_net(onnx_model.graph, device="CPU")
  File "/opt/DL/pytorch/lib/python2.7/site-packages/caffe2/python/onnx/backend.py", line 923, in onnx_graph_to_caffe2_net
    return cls._onnx_model_to_caffe2_net(model, device=device, opset_version=opset_version, include_initializers=True)
  File "/opt/DL/pytorch/lib/python2.7/site-packages/caffe2/python/onnx/backend.py", line 881, in _onnx_model_to_caffe2_net
    onnx_model = onnx.utils.polish_model(onnx_model)
  File "/home/builder/anaconda2/lib/python2.7/site-packages/onnx/utils.py", line 18, in polish_model
    onnx.checker.check_model(model)
  File "/home/builder/anaconda2/lib/python2.7/site-packages/onnx/checker.py", line 83, in check_model
    C.check_model(model.SerializeToString())
onnx.onnx_cpp2py_export.checker.ValidationError: The model does not have an ir_version set properly.

However, after the fix, we are receiving an error during the benchmark_caffe2_model call.

    caffe2_time = benchmark_caffe2_model(init_net, predict_net)
  File "/opt/DL/pytorch/lib/python2.7/site-packages/caffe2/python/onnx/helper.py", line 92, in benchmark_caffe2_model
    ws.CreateNet(predict_net,True)
  File "/opt/DL/pytorch/lib/python2.7/site-packages/caffe2/python/onnx/workspace.py", line 63, in f
    return getattr(workspace, attr)(*args, **kwargs)
  File "/opt/DL/pytorch/lib/python2.7/site-packages/caffe2/python/workspace.py", line 156, in CreateNet
    StringifyProto(net), overwrite,
  File "/opt/DL/pytorch/lib/python2.7/site-packages/caffe2/python/workspace.py", line 182, in CallWithExceptionIntercept
    return func(*args, **kwargs)
RuntimeError: [enforce fail at operator.cc:46] blob != nullptr. op Conv: Encountered a non-existing input blob: 0

Would I be able to get some assistance in debugging this issue? Our relevant code levels are pytorch=1.0.0, onnx=1.3.0

If you need more information please let me know!

sanjay23singh commented 2 years ago

hey, @dllehr81 did you find any solution for this?