onnx: Import error on Raspberry Pi 3
I installed onnx on Raspberry Pi 3 in a non-Anaconda environment(Python 3.5.3).
sudo apt-get install protobuf-compiler libprotoc-dev
pip install onnx
I seemed to succeed in installing.
Installing collected packages: numpy, six, setuptools, protobuf, onnx
Successfully installed numpy-1.13.3 onnx-1.0.0 protobuf-3.5.1 setuptools-38.2.5 six-1.11.0
However, I couldn’t import onnx.
>>> import onnx
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/pi/.local/lib/python3.5/site-packages/onnx/__init__.py", line 10, in <module>
import onnx.helper # noqa
File "/home/pi/.local/lib/python3.5/site-packages/onnx/helper.py", line 15, in <module>
import onnx.defs as defs
File "/home/pi/.local/lib/python3.5/site-packages/onnx/defs/__init__.py", line 6, in <module>
import onnx.onnx_cpp2py_export.defs as C
ImportError: /home/pi/.local/lib/python3.5/site-packages/onnx/onnx_cpp2py_export.cpython-35m-
arm-linux-gnueabihf.so: undefined symbol:
_ZNK6google8protobuf7Message11GetTypeNameB5cxx11Ev
Can anyone help us determine the possible cause?
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 16 (4 by maintainers)
The
cxx11in the missing symbol name suggests maybe that you are compiling with the new C++11 ABI, but the protobuf you are using is somehow on the old ABI. One possibility is that pip is downloading and installing a wheel that was built with the old C++11 ABI. To see if this is the case, I need to see the entire install log; e.g., blow away anything pip installed previously (pip uninstall numpy six setuptools protobuf onnx) and then report the FULL log when you runpip install -v onnx. You can also disable wheels by passing--no-binary(of course, now you will have to build these deps.)Another possibility is that ONNX is being built with the C++11 ABI when it shouldn’t. You can disable this by passing
CFLAGS="-D_GLIBCXX_USE_CXX11_ABI=0"as an environment variable.Please let us know what the problem is in the end so we can help other users. Thanks.
@linkerzhang Note that conda is not an option here, because conda-forge does not currently do ARM builds: https://github.com/conda-forge/conda-forge.github.io/issues/269
I had the exact same error when trying to build onnx on raspberry pi. I managed to solve the issue by adding the following to setup.py so that the compiler uses the old ABI:
extra_compile_args += [ '-D_GLIBCXX_USE_CXX11_ABI=0']Thanks @ezyang for pointing me in the direction.