undefined symbol: _ZNK6google8protobuf7Message11GetTypeNameEv
See original GitHub issue**I have successfully install with plugins, but I can not import the plugins still, the following is my log. **
[3/3] g++ -shared -o torch2trt/libtorc…obuf-lite -pthread -lpthread -lnvinfer running install running bdist_egg running egg_info writing torch2trt.egg-info/PKG-INFO writing dependency_links to torch2trt.egg-info/dependency_links.txt writing top-level names to torch2trt.egg-info/top_level.txt reading manifest file ‘torch2trt.egg-info/SOURCES.txt’ writing manifest file ‘torch2trt.egg-info/SOURCES.txt’ installing library code to build/bdist.linux-x86_64/egg running install_lib running build_py copying torch2trt/init.py -> build/lib/torch2trt creating build/bdist.linux-x86_64/egg creating build/bdist.linux-x86_64/egg/torch2trt copying build/lib/torch2trt/libtorch2trt.so -> build/bdist.linux-x86_64/egg/torch2trt copying build/lib/torch2trt/test.py -> build/bdist.linux-x86_64/egg/torch2trt copying build/lib/torch2trt/module_test.py -> build/bdist.linux-x86_64/egg/torch2trt creating build/bdist.linux-x86_64/egg/torch2trt/converters copying build/lib/torch2trt/converters/pad.py -> build/bdist.linux-x86_64/egg/torch2trt/converters copying build/lib/torch2trt/converters/Conv2d.py -> build/bdist.linux-x86_64/egg/torch2trt/converters copying build/lib/torch2trt/converters/sigmoid.py -> build/bdist.linux-x86_64/egg/torch2trt/converters copying build/lib/torch2trt/converters/BatchNorm2d.py -> build/bdist.linux-x86_64/egg/torch2trt/converters copying build/lib/torch2trt/converters/add.py -> build/bdist.linux-x86_64/egg/torch2trt/converters copying build/lib/torch2trt/converters/AvgPool2d.py -> build/bdist.linux-x86_64/egg/torch2trt/converters copying build/lib/torch2trt/converters/MaxPool2d.py -> build/bdist.linux-x86_64/egg/torch2trt/converters copying build/lib/torch2trt/converters/ReLU.py -> build/bdist.linux-x86_64/egg/torch2trt/converters copying build/lib/torch2trt/converters/mul.py -> build/bdist.linux-x86_64/egg/torch2trt/converters copying build/lib/torch2trt/converters/cat.py -> build/bdist.linux-x86_64/egg/torch2trt/converters copying build/lib/torch2trt/converters/softmax.py -> build/bdist.linux-x86_64/egg/torch2trt/converters copying build/lib/torch2trt/converters/ConvTranspose2d.py -> build/bdist.linux-x86_64/egg/torch2trt/converters copying build/lib/torch2trt/converters/AdaptiveAvgPool2d.py -> build/bdist.linux-x86_64/egg/torch2trt/converters copying build/lib/torch2trt/converters/identity.py -> build/bdist.linux-x86_64/egg/torch2trt/converters copying build/lib/torch2trt/converters/Linear.py -> build/bdist.linux-x86_64/egg/torch2trt/converters copying build/lib/torch2trt/converters/ReLU6.py -> build/bdist.linux-x86_64/egg/torch2trt/converters copying build/lib/torch2trt/converters/tanh.py -> build/bdist.linux-x86_64/egg/torch2trt/converters copying build/lib/torch2trt/converters/init.py -> build/bdist.linux-x86_64/egg/torch2trt/converters copying build/lib/torch2trt/converters/Conv1d.py -> build/bdist.linux-x86_64/egg/torch2trt/converters copying build/lib/torch2trt/converters/relu.py -> build/bdist.linux-x86_64/egg/torch2trt/converters copying build/lib/torch2trt/converters/view.py -> build/bdist.linux-x86_64/egg/torch2trt/converters copying build/lib/torch2trt/converters/Identity.py -> build/bdist.linux-x86_64/egg/torch2trt/converters copying build/lib/torch2trt/converters/SynchronizedBatchNorm2d.py -> build/bdist.linux-x86_64/egg/torch2trt/converters copying build/lib/torch2trt/converters/relu6.py -> build/bdist.linux-x86_64/egg/torch2trt/converters copying build/lib/torch2trt/converters/LogSoftmax.py -> build/bdist.linux-x86_64/egg/torch2trt/converters copying build/lib/torch2trt/converters/adaptive_avg_pool2d.py -> build/bdist.linux-x86_64/egg/torch2trt/converters copying build/lib/torch2trt/converters/BatchNorm1d.py -> build/bdist.linux-x86_64/egg/torch2trt/converters copying build/lib/torch2trt/converters/div.py -> build/bdist.linux-x86_64/egg/torch2trt/converters copying build/lib/torch2trt/converters/transpose.py -> build/bdist.linux-x86_64/egg/torch2trt/converters copying build/lib/torch2trt/converters/iadd.py -> build/bdist.linux-x86_64/egg/torch2trt/converters creating build/bdist.linux-x86_64/egg/torch2trt/converters/interpolate copying build/lib/torch2trt/converters/interpolate/interpolate.py -> build/bdist.linux-x86_64/egg/torch2trt/converters/interpolate copying build/lib/torch2trt/converters/interpolate/init.py -> build/bdist.linux-x86_64/egg/torch2trt/converters/interpolate copying build/lib/torch2trt/converters/interpolate/interpolate_pb2.py -> build/bdist.linux-x86_64/egg/torch2trt/converters/interpolate copying build/lib/torch2trt/converters/mean.py -> build/bdist.linux-x86_64/egg/torch2trt/converters copying build/lib/torch2trt/init.py -> build/bdist.linux-x86_64/egg/torch2trt copying build/lib/torch2trt/torch2trt.py -> build/bdist.linux-x86_64/egg/torch2trt byte-compiling build/bdist.linux-x86_64/egg/torch2trt/test.py to test.cpython-36.pyc byte-compiling build/bdist.linux-x86_64/egg/torch2trt/module_test.py to module_test.cpython-36.pyc byte-compiling build/bdist.linux-x86_64/egg/torch2trt/converters/pad.py to pad.cpython-36.pyc byte-compiling build/bdist.linux-x86_64/egg/torch2trt/converters/Conv2d.py to Conv2d.cpython-36.pyc byte-compiling build/bdist.linux-x86_64/egg/torch2trt/converters/sigmoid.py to sigmoid.cpython-36.pyc byte-compiling build/bdist.linux-x86_64/egg/torch2trt/converters/BatchNorm2d.py to BatchNorm2d.cpython-36.pyc byte-compiling build/bdist.linux-x86_64/egg/torch2trt/converters/add.py to add.cpython-36.pyc byte-compiling build/bdist.linux-x86_64/egg/torch2trt/converters/AvgPool2d.py to AvgPool2d.cpython-36.pyc byte-compiling build/bdist.linux-x86_64/egg/torch2trt/converters/MaxPool2d.py to MaxPool2d.cpython-36.pyc byte-compiling build/bdist.linux-x86_64/egg/torch2trt/converters/ReLU.py to ReLU.cpython-36.pyc byte-compiling build/bdist.linux-x86_64/egg/torch2trt/converters/mul.py to mul.cpython-36.pyc byte-compiling build/bdist.linux-x86_64/egg/torch2trt/converters/cat.py to cat.cpython-36.pyc byte-compiling build/bdist.linux-x86_64/egg/torch2trt/converters/softmax.py to softmax.cpython-36.pyc byte-compiling build/bdist.linux-x86_64/egg/torch2trt/converters/ConvTranspose2d.py to ConvTranspose2d.cpython-36.pyc byte-compiling build/bdist.linux-x86_64/egg/torch2trt/converters/AdaptiveAvgPool2d.py to AdaptiveAvgPool2d.cpython-36.pyc byte-compiling build/bdist.linux-x86_64/egg/torch2trt/converters/identity.py to identity.cpython-36.pyc byte-compiling build/bdist.linux-x86_64/egg/torch2trt/converters/Linear.py to Linear.cpython-36.pyc byte-compiling build/bdist.linux-x86_64/egg/torch2trt/converters/ReLU6.py to ReLU6.cpython-36.pyc byte-compiling build/bdist.linux-x86_64/egg/torch2trt/converters/tanh.py to tanh.cpython-36.pyc byte-compiling build/bdist.linux-x86_64/egg/torch2trt/converters/init.py to init.cpython-36.pyc byte-compiling build/bdist.linux-x86_64/egg/torch2trt/converters/Conv1d.py to Conv1d.cpython-36.pyc byte-compiling build/bdist.linux-x86_64/egg/torch2trt/converters/relu.py to relu.cpython-36.pyc byte-compiling build/bdist.linux-x86_64/egg/torch2trt/converters/view.py to view.cpython-36.pyc byte-compiling build/bdist.linux-x86_64/egg/torch2trt/converters/Identity.py to Identity.cpython-36.pyc byte-compiling build/bdist.linux-x86_64/egg/torch2trt/converters/SynchronizedBatchNorm2d.py to SynchronizedBatchNorm2d.cpython-36.pyc byte-compiling build/bdist.linux-x86_64/egg/torch2trt/converters/relu6.py to relu6.cpython-36.pyc byte-compiling build/bdist.linux-x86_64/egg/torch2trt/converters/LogSoftmax.py to LogSoftmax.cpython-36.pyc byte-compiling build/bdist.linux-x86_64/egg/torch2trt/converters/adaptive_avg_pool2d.py to adaptive_avg_pool2d.cpython-36.pyc byte-compiling build/bdist.linux-x86_64/egg/torch2trt/converters/BatchNorm1d.py to BatchNorm1d.cpython-36.pyc byte-compiling build/bdist.linux-x86_64/egg/torch2trt/converters/div.py to div.cpython-36.pyc byte-compiling build/bdist.linux-x86_64/egg/torch2trt/converters/transpose.py to transpose.cpython-36.pyc byte-compiling build/bdist.linux-x86_64/egg/torch2trt/converters/iadd.py to iadd.cpython-36.pyc byte-compiling build/bdist.linux-x86_64/egg/torch2trt/converters/interpolate/interpolate.py to interpolate.cpython-36.pyc byte-compiling build/bdist.linux-x86_64/egg/torch2trt/converters/interpolate/init.py to init.cpython-36.pyc byte-compiling build/bdist.linux-x86_64/egg/torch2trt/converters/interpolate/interpolate_pb2.py to interpolate_pb2.cpython-36.pyc byte-compiling build/bdist.linux-x86_64/egg/torch2trt/converters/mean.py to mean.cpython-36.pyc byte-compiling build/bdist.linux-x86_64/egg/torch2trt/init.py to init.cpython-36.pyc byte-compiling build/bdist.linux-x86_64/egg/torch2trt/torch2trt.py to torch2trt.cpython-36.pyc creating build/bdist.linux-x86_64/egg/EGG-INFO copying torch2trt.egg-info/PKG-INFO -> build/bdist.linux-x86_64/egg/EGG-INFO copying torch2trt.egg-info/SOURCES.txt -> build/bdist.linux-x86_64/egg/EGG-INFO copying torch2trt.egg-info/dependency_links.txt -> build/bdist.linux-x86_64/egg/EGG-INFO copying torch2trt.egg-info/top_level.txt -> build/bdist.linux-x86_64/egg/EGG-INFO writing build/bdist.linux-x86_64/egg/EGG-INFO/native_libs.txt zip_safe flag not set; analyzing archive contents… torch2trt.pycache.init.cpython-36: module references file creating ‘dist/torch2trt-0.0.0-py3.6.egg’ and adding ‘build/bdist.linux-x86_64/egg’ to it removing ‘build/bdist.linux-x86_64/egg’ (and everything under it) Processing torch2trt-0.0.0-py3.6.egg removing ‘/home/yangqh/Envs/torch.1.1/lib/python3.6/site-packages/torch2trt-0.0.0-py3.6.egg’ (and everything under it) creating /home/yangqh/Envs/torch.1.1/lib/python3.6/site-packages/torch2trt-0.0.0-py3.6.egg Extracting torch2trt-0.0.0-py3.6.egg to /home/yangqh/Envs/torch.1.1/lib/python3.6/site-packages torch2trt 0.0.0 is already the active version in easy-install.pth Installed /home/yangqh/Envs/torch.1.1/lib/python3.6/site-packages/torch2trt-0.0.0-py3.6.egg Processing dependencies for torch2trt==0.0.0 Finished processing dependencies for torch2trt==0.0.0
I have followed #12 and #17, It solves the problem of compile, but I can not import the plugins. So I modify the code of torch2rt/torch2rt/init.py to see what error message is. I comment the “try except”,
instead I add the line
load_plugins() PLUGINS_LOADED = True
I rebuilded it with flag -D_GLIBCXX_USE_CXX11_ABI=0, then I use python -m torch2trt.test -name=interpolate to test it again, It occurs the error message
OSError: /home/yangqh/workspace/torch2trt/torch2trt/libtorch2trt.so: undefined symbol: _ZNK6google8protobuf7Message11GetTypeNameEv
If I rebuild it without flag -D_GLIBCXX_USE_CXX11_ABI=0, It occurs error message
/home/yangqh/Envs/torch.1.1/lib/python3.6/site-packages/torch2trt-0.0.0-py3.6.egg/torch2trt/libtorch2trt.so: undefined symbol: _ZN3c105ErrorC1ENS_14SourceLocationERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
My environment is
Collecting environment information… PyTorch version: 1.1.0 Is debug build: No CUDA used to build PyTorch: 9.0.176 OS: Ubuntu 16.04.6 LTS GCC version: (Ubuntu 5.4.0-6ubuntu1~16.04.11) 5.4.0 20160609 CMake version: version 3.5.1 Python version: 3.6 Is CUDA available: Yes CUDA runtime version: 9.0.176 GPU models and configuration: GPU 0: GeForce GTX 1060 6GB Nvidia driver version: 390.87 cuDNN version: /usr/lib/x86_64-linux-gnu/libcudnn.so.7.4.1 Versions of relevant libraries: [pip3] numpy==1.16.3 [pip3] torch==1.1.0 [pip3] torch2trt==0.0.0 [pip3] torchvision==0.3.0 [conda] Could not collect Other package: protobuf-3.9.1/ [build from source] TensorRT-5.1.5.0/
I don’t know what’s the problem, do you have any suggestions ? @jaybdub
Issue Analytics
- State:
- Created 4 years ago
- Comments:12 (2 by maintainers)
Top GitHub Comments
After a hard trying, I think I haved solved problem.
1.Usually, errors of ‘undefined symbol’ are link errors ‘undefined symbol’ means this *.so file can not find the symbol. There are two situations may cause this error: 1. during the linking phase of compiling, the *so file was not provided to the g++ compiler. so just check the path of libprotobuf.so is whether in the ninja rule of compiling. If not, add it. here is my link rule in build.py, I add -L/usr/lib in it:
2.compiler(linker) did link to the other .so file, but can’t find the symbol. For the situation here, it means libtorch2trt.so has linked to libprotobuf.so but can’t find the symbol( function entry point) – _ZNK6google8protobuf7Message11GetTypeNameEv You may check this with :
This will show the shared library it has linked and also the missing symbol. However, for situation 2 ,the symbol is not really missing, but has a different name due to the different version of g++ compiler. to see the symbol( function entry point ) of a *.so file , you may run the line below:
for checking whether a *.so file has a specific name func , run the line below:
For some cases , different gcc compiler would give different styles of function names in *.so file. For some func xxxx, older g++ which do not support cxx11 would give name like: _Z4xxxxyy, newer g++ which use cxx11 ABI as default would give name like _ZN4xxxxyy__cxx11:baiscstring… . When this happends, linker would be confused and can’t find the symbol. So usually you need to recompile the 2 projects with same g++ compiler and link them.
Here are my cases: os: centos7 torch: pip install torch ( ver1.3 )( notice that symbols in libtorch.so didn’t have name like __cxx11 ,which means don’t make your g++ version too high ) g++ : 7.3 .1( use : scl enable devtoolset-7 bash ) protobuf:3.1.0 ( notice that this version of protobuf require g++ to support c++11 ,which means g++5 or higher ) tensorrt: 6.0.1.5 cuda:10.1 cudnn:7.6.4
so i just use g++7.3 and recompile protobuf and torch2trt, and then I passed.
Hello, I think there exists 2 way to solve the problem. a) method one(If you install pytorch by pip or conda)
I used method one to solve the problem