Similar to #2808 apple/coremltools#920 and #2940
The script crashes when onnx is imported after pytorch. The script completes successfully when onnx is imported before pytorch, or when onnx installed version <= 1.7.0
# import onnx # uncomment and pass
import torch
from onnx import ModelProto
class M(torch.nn.Module):
def forward(self, x, y):
return x + y
x = torch.randn(2, 3)
y = torch.randn(2, 3)
import io
f = io.BytesIO()
torch.onnx.export(M(), (x, y), f, verbose=True, input_names=['x', 'y'])
Both packages are installed like below
pip install torch==1.8.1+cpu -f https://download.pytorch.org/whl/torch_stable.html
pip install onnx==1.8
Based on previous issues, I suspect this is also related to different protobuf versions. Can someone explain what is going on underneath, and how to resolve & prevent this in the future?