onnx / onnx-caffe2

Caffe2 implementation of Open Neural Network Exchange (ONNX)
Other
165 stars 66 forks source link

convert-caffe2-to-onnx get error : "Segmentation fault (core dumped)" #292

Open icortana opened 6 years ago

icortana commented 6 years ago

Hi, I'm trying to convert caffe2 model to onnx model, but simply type convert-caffe2-to-onnx will get this error : "Segmentation fault (core dumped)".

I have tried the following environments :

Ubuntu 16.04.4 LTS, Python 3.6 Caffe2 CPU;
Ubuntu 16.04.4 LTS, Python 3.6 Caffe2 GPU CUDA 9.0 CuDNN7;
Caffe2 docker Ubuntu 16.04.2 LTS, Python 2.7 Caffe2 CPU;

They all get the same result.

ezyang commented 6 years ago

Can you use gdb to get a backtrace and post it here?

icortana commented 6 years ago
(gdb) r caffe2onnx.py
Starting program: /root/anaconda3/bin/python caffe2onnx.py
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".

Program received signal SIGSEGV, Segmentation fault.
0x00007fffef0b2d69 in pybind11::detail::make_new_python_type(pybind11::detail::type_record const&) ()
   from /root/anaconda3/lib/python3.6/site-packages/caffe2/python/caffe2_pybind11_state_gpu.cpython-36m-x86_64-linux-gnu.so
(gdb) bt
#0  0x00007fffef0b2d69 in pybind11::detail::make_new_python_type(pybind11::detail::type_record const&) ()
   from /root/anaconda3/lib/python3.6/site-packages/caffe2/python/caffe2_pybind11_state_gpu.cpython-36m-x86_64-linux-gnu.so
#1  0x00007fffef0b5968 in pybind11::detail::generic_type::initialize(pybind11::detail::type_record const&) ()
   from /root/anaconda3/lib/python3.6/site-packages/caffe2/python/caffe2_pybind11_state_gpu.cpython-36m-x86_64-linux-gnu.so
#2  0x00007fffef0b6061 in pybind11::class_<caffe2::NetBase>::class_<>(pybind11::handle, char const*) ()
   from /root/anaconda3/lib/python3.6/site-packages/caffe2/python/caffe2_pybind11_state_gpu.cpython-36m-x86_64-linux-gnu.so
#3  0x00007fffef084fa1 in caffe2::python::addObjectMethods(pybind11::module&) ()
   from /root/anaconda3/lib/python3.6/site-packages/caffe2/python/caffe2_pybind11_state_gpu.cpython-36m-x86_64-linux-gnu.so
#4  0x00007fffef0e43a4 in PyInit_caffe2_pybind11_state_gpu ()
   from /root/anaconda3/lib/python3.6/site-packages/caffe2/python/caffe2_pybind11_state_gpu.cpython-36m-x86_64-linux-gnu.so
#5  0x00000000082158e5 in _PyImport_LoadDynamicModuleWithSpec ()
#6  0x0000000008215ae5 in _imp_create_dynamic ()
#7  0x0000000008111a61 in PyCFunction_Call ()
#8  0x00000000081c5fdb in _PyEval_EvalFrameDefault ()
#9  0x0000000008197a94 in _PyEval_EvalCodeWithName ()
#10 0x0000000008198941 in fast_function ()
#11 0x000000000819e755 in call_function ()
#12 0x00000000081c0cba in _PyEval_EvalFrameDefault ()
#13 0x000000000819870b in fast_function ()
#14 0x000000000819e755 in call_function ()
#15 0x00000000081c0cba in _PyEval_EvalFrameDefault ()
#16 0x000000000819870b in fast_function ()
#17 0x000000000819e755 in call_function ()
#18 0x00000000081c0cba in _PyEval_EvalFrameDefault ()
---Type <return> to continue, or q <return> to quit---
#19 0x000000000819870b in fast_function ()
#20 0x000000000819e755 in call_function ()
#21 0x00000000081c0cba in _PyEval_EvalFrameDefault ()
#22 0x000000000819870b in fast_function ()
#23 0x000000000819e755 in call_function ()
#24 0x00000000081c0cba in _PyEval_EvalFrameDefault ()
#25 0x0000000008198d7b in _PyFunction_FastCallDict ()
#26 0x000000000810ef5f in _PyObject_FastCallDict ()
#27 0x0000000008153670 in _PyObject_CallMethodIdObjArgs ()
#28 0x0000000008105a70 in PyImport_ImportModuleLevelObject ()
#29 0x00000000081c3033 in _PyEval_EvalFrameDefault ()
#30 0x0000000008199459 in PyEval_EvalCodeEx ()
#31 0x000000000819a1ec in PyEval_EvalCode ()
#32 0x00000000081be5bd in builtin_exec ()
#33 0x0000000008111a61 in PyCFunction_Call ()
#34 0x00000000081c5fdb in _PyEval_EvalFrameDefault ()
#35 0x0000000008197a94 in _PyEval_EvalCodeWithName ()
#36 0x0000000008198941 in fast_function ()
#37 0x000000000819e755 in call_function ()
#38 0x00000000081c0cba in _PyEval_EvalFrameDefault ()
#39 0x000000000819870b in fast_function ()
#40 0x000000000819e755 in call_function ()
#41 0x00000000081c0cba in _PyEval_EvalFrameDefault ()
#42 0x000000000819870b in fast_function ()
#43 0x000000000819e755 in call_function ()
#44 0x00000000081c0cba in _PyEval_EvalFrameDefault ()
#45 0x000000000819870b in fast_function ()
#46 0x000000000819e755 in call_function ()
#47 0x00000000081c0cba in _PyEval_EvalFrameDefault ()
#48 0x0000000008198d7b in _PyFunction_FastCallDict ()
#49 0x000000000810ef5f in _PyObject_FastCallDict ()
#50 0x0000000008153670 in _PyObject_CallMethodIdObjArgs ()
#51 0x0000000008105a70 in PyImport_ImportModuleLevelObject ()
#52 0x00000000081c3033 in _PyEval_EvalFrameDefault ()
#53 0x0000000008199459 in PyEval_EvalCodeEx ()
#54 0x000000000819a1ec in PyEval_EvalCode ()
#55 0x00000000081be5bd in builtin_exec ()
#56 0x0000000008111a61 in PyCFunction_Call ()
#57 0x00000000081c5fdb in _PyEval_EvalFrameDefault ()
#58 0x0000000008197a94 in _PyEval_EvalCodeWithName ()
#59 0x0000000008198941 in fast_function ()
#60 0x000000000819e755 in call_function ()
#61 0x00000000081c0cba in _PyEval_EvalFrameDefault ()
#62 0x000000000819870b in fast_function ()
#63 0x000000000819e755 in call_function ()
#64 0x00000000081c0cba in _PyEval_EvalFrameDefault ()
#65 0x000000000819870b in fast_function ()
#66 0x000000000819e755 in call_function ()
#67 0x00000000081c0cba in _PyEval_EvalFrameDefault ()
#68 0x000000000819870b in fast_function ()
#69 0x000000000819e755 in call_function ()
#70 0x00000000081c0cba in _PyEval_EvalFrameDefault ()
#71 0x0000000008198d7b in _PyFunction_FastCallDict ()
#72 0x000000000810ef5f in _PyObject_FastCallDict ()
#73 0x0000000008153670 in _PyObject_CallMethodIdObjArgs ()
#74 0x0000000008105a70 in PyImport_ImportModuleLevelObject ()
#75 0x00000000081a91da in builtin___import__ ()
#76 0x00000000081119f6 in PyCFunction_Call ()
#77 0x00000000081c5fdb in _PyEval_EvalFrameDefault ()
#78 0x0000000008197a94 in _PyEval_EvalCodeWithName ()
#79 0x0000000008198941 in fast_function ()
#80 0x000000000819e755 in call_function ()
---Type <return> to continue, or q <return> to quit---
#81 0x00000000081c0cba in _PyEval_EvalFrameDefault ()
#82 0x0000000008197f21 in _PyEval_EvalCodeWithName ()
#83 0x0000000008198e1b in _PyFunction_FastCallDict ()
#84 0x000000000810ef5f in _PyObject_FastCallDict ()
#85 0x0000000008153670 in _PyObject_CallMethodIdObjArgs ()
#86 0x0000000008105933 in PyImport_ImportModuleLevelObject ()
#87 0x00000000081c3033 in _PyEval_EvalFrameDefault ()
#88 0x0000000008199459 in PyEval_EvalCodeEx ()
#89 0x000000000819a1ec in PyEval_EvalCode ()
#90 0x00000000081be5bd in builtin_exec ()
#91 0x0000000008111a61 in PyCFunction_Call ()
#92 0x00000000081c5fdb in _PyEval_EvalFrameDefault ()
#93 0x0000000008197a94 in _PyEval_EvalCodeWithName ()
#94 0x0000000008198941 in fast_function ()
#95 0x000000000819e755 in call_function ()
#96 0x00000000081c0cba in _PyEval_EvalFrameDefault ()
#97 0x000000000819870b in fast_function ()
#98 0x000000000819e755 in call_function ()
#99 0x00000000081c0cba in _PyEval_EvalFrameDefault ()
#100 0x000000000819870b in fast_function ()
#101 0x000000000819e755 in call_function ()
#102 0x00000000081c0cba in _PyEval_EvalFrameDefault ()
#103 0x000000000819870b in fast_function ()
#104 0x000000000819e755 in call_function ()
#105 0x00000000081c0cba in _PyEval_EvalFrameDefault ()
#106 0x0000000008198d7b in _PyFunction_FastCallDict ()
#107 0x000000000810ef5f in _PyObject_FastCallDict ()
#108 0x0000000008153670 in _PyObject_CallMethodIdObjArgs ()
#109 0x0000000008105a70 in PyImport_ImportModuleLevelObject ()
#110 0x00000000081a91da in builtin___import__ ()
#111 0x00000000081119f6 in PyCFunction_Call ()
#112 0x00000000081c5fdb in _PyEval_EvalFrameDefault ()
#113 0x0000000008197a94 in _PyEval_EvalCodeWithName ()
#114 0x0000000008198941 in fast_function ()
#115 0x000000000819e755 in call_function ()
#116 0x00000000081c0cba in _PyEval_EvalFrameDefault ()
#117 0x0000000008197f21 in _PyEval_EvalCodeWithName ()
#118 0x0000000008198e1b in _PyFunction_FastCallDict ()
#119 0x000000000810ef5f in _PyObject_FastCallDict ()
#120 0x0000000008153670 in _PyObject_CallMethodIdObjArgs ()
#121 0x0000000008105933 in PyImport_ImportModuleLevelObject ()
#122 0x00000000081c3033 in _PyEval_EvalFrameDefault ()
#123 0x0000000008199459 in PyEval_EvalCodeEx ()
#124 0x000000000819a1ec in PyEval_EvalCode ()
#125 0x00000000081be5bd in builtin_exec ()
#126 0x0000000008111a61 in PyCFunction_Call ()
#127 0x00000000081c5fdb in _PyEval_EvalFrameDefault ()
#128 0x0000000008197a94 in _PyEval_EvalCodeWithName ()
#129 0x0000000008198941 in fast_function ()
#130 0x000000000819e755 in call_function ()
#131 0x00000000081c0cba in _PyEval_EvalFrameDefault ()
#132 0x000000000819870b in fast_function ()
#133 0x000000000819e755 in call_function ()
#134 0x00000000081c0cba in _PyEval_EvalFrameDefault ()
#135 0x000000000819870b in fast_function ()
#136 0x000000000819e755 in call_function ()
#137 0x00000000081c0cba in _PyEval_EvalFrameDefault ()
#138 0x000000000819870b in fast_function ()
#139 0x000000000819e755 in call_function ()
#140 0x00000000081c0cba in _PyEval_EvalFrameDefault ()
#141 0x0000000008198d7b in _PyFunction_FastCallDict ()
#142 0x000000000810ef5f in _PyObject_FastCallDict ()
---Type <return> to continue, or q <return> to quit---
#143 0x0000000008153670 in _PyObject_CallMethodIdObjArgs ()
#144 0x0000000008105a70 in PyImport_ImportModuleLevelObject ()
#145 0x00000000081c3033 in _PyEval_EvalFrameDefault ()
#146 0x0000000008199459 in PyEval_EvalCodeEx ()
#147 0x000000000819a1ec in PyEval_EvalCode ()
#148 0x00000000082149a4 in run_mod ()
#149 0x0000000008214da1 in PyRun_FileExFlags ()
#150 0x0000000008214fa4 in PyRun_SimpleFileExFlags ()
#151 0x0000000008218a9e in Py_Main ()
#152 0x00000000080e04be in main ()
(gdb)

caffe2onnx.py :

import onnx
import caffe2.python.onnx.frontend
from caffe2.proto import caffe2_pb2

# We need to provide type and shape of the model inputs,
# see above Note section for explanation
data_type = onnx.TensorProto.FLOAT
data_shape = (1, 3, 224, 224)
value_info = {
    'data': (data_type, data_shape)
}

predict_net = caffe2_pb2.NetDef()
with open('predict_net.pb', 'rb') as f:
    predict_net.ParseFromString(f.read())

init_net = caffe2_pb2.NetDef()
with open('init_net.pb', 'rb') as f:
    init_net.ParseFromString(f.read())

onnx_model = caffe2.python.onnx.frontend.caffe2_net_to_onnx_model(
    predict_net,
    init_net,
    value_info,
)

onnx.checker.check_model(onnx_model)
muthiyanbhushan commented 6 years ago

I am also having same issue. Any suggestions?

Thanks.