tutorials
tutorials copied to clipboard
Segmentation fault while trying to run "torch.onnx.export"
I was running into segmentation fault issue while trying to export onnx model. and the component we use is Python 3.5.4 , torch-0.4.1, Ubuntu 14.04
>>> from torch.autograd import Variable
>>> import torch.onnx
>>> import torchvision
>>>
>>> # Standard ImageNet input - 3 channels, 224x224,
... # values don't matter as we care about network structure.
... # But they can also be real inputs.
... dummy_input = Variable(torch.randn(1, 3, 224, 224))
>>> # Obtain your model, it can be also constructed in your script explicitly
... model = torchvision.models.alexnet(pretrained=True)
>>> # Invoke export
...
>>> torch.onnx.export(model, dummy_input, "alexnet.onnx")
Segmentation fault (core dumped)
I guess, that's because of the C++ ABI issue. Try to install the pytorch and onnx both from source.