question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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:closed
  • Created 4 years ago
  • Comments:12 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
ThreeChencommented, Nov 16, 2019

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:

    "rule link\n"
"  command = g++ -shared -o $$out $$in **-L/usr/lib** -L$torch_dir/lib -L$cuda_dir/lib64 -L$trt_lib_dir -lc10 -lc10_cuda -ltorch -lcudart -lprotobuf -lprotobuf-lite -pthread -lpthread -lnvinfer\n"

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 :

    ldd -r libtorch2trt.so

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:

    nm -a *.so

for checking whether a *.so file has a specific name func , run the line below:

    strings *.so | grep xxxx

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.

2reactions
Tiamo666commented, Oct 17, 2019

Hello, I think there exists 2 way to solve the problem. a) method one(If you install pytorch by pip or conda)

  1. Lower down your gcc and g++ version from 5 to 4.8.(As the change about the ABI issue)
  2. build the protobuf
  3. build the plugin with flag -D_GLIBCXX_USE_CXX11_ABI=0 b) Method two
  4. Build pytorch from source with gcc > 4.8
  5. build the protobuf
  6. build the plugin without flag -D_GLIBCXX_USE_CXX11_ABI=0

I used method one to solve the problem

Read more comments on GitHub >

github_iconTop Results From Across the Web

tfrnnlm _pywrap_tensorflow_internal.so: undefined symbol ...
I wanted to utilize the tfrnnlm module to rescore the lattice and ran into this mistake. my tensorflow version is 1.4. it seems...
Read more >
tfrnnlm _pywrap_tensorflow_internal.so: undefined symbol
I wanted to utilize the tfrnnlm module to rescore the lattice and ran into this mistake. my tensorflow version is 1.4. it seems...
Read more >
CSDN博客_undefined symbol
Q1:undefined symbol: _ZNK6google8protobuf7Message11GetTypeNameEv. Q2:importError: cannot import name 'descriptor'. 更新protobuf.
Read more >
undefined symbol in shared lib on Ubuntu 10.04
Issue 177 in protobuf: undefined symbol in shared lib on Ubuntu 10.04 ... At runtime: undefined symbol: _ZNK6google8protobuf7Message11GetTypeNameEv.
Read more >
undefined symbol - Stack Overflow
undefined symbol : _ZNK6google8protobuf7Message25InitializationErrorStringEv ; import reverb Traceback (most recent call last): File "<stdin>" ; in ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found