-
Notifications
You must be signed in to change notification settings - Fork 1.3k
undefined symbol: _ZN6google8Protobuf8in....... when testing test_zero_even_op.py #119
Comments
Same error here, using Anaconda python 3.5.6 and built using gcc 6.
|
I also also have the same problem: $ python2 detectron/tests/test_zero_even_op.py #System: |
I can run the demo although I still have this error.. |
This error occurs when several versions of google protocol buffers clash: one is typically embedded into PyTorch / Caffe2, the other one is the system one. Solution would be to either use the system protocol buffers when building PyTorch / Caffe2, or use the one from PyTorch / Caffe2 when building custom ops. |
@vkhalidov I tried to build caffe2 from source and the same error. I've turned to docker. |
@vkhalidov How can we use the protobuf from pytorch when building custom ops? What changes should I make to the build instructions? |
One of simple solutions is to use protobuf from the conda installation # you need to set CONDA_ROOT env variable.
set(PROTOBUF_LIB $ENV{CONDA_ROOT}/lib/libprotobuf.a) If you built caffe2 from source, then # I'm using virtualenv.
set(PROTOBUF_LIB "$ENV{VIRTUAL_ENV}/lib/python2.7/site-packages/torch/lib/libprotobuf.a") FYI, my local version of CMakeLists.txt is as follows diff --git a/CMakeLists.txt b/CMakeLists.txt
index 488ea86..1efacab 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -34,7 +34,12 @@ add_library(
caffe2_detectron_custom_ops SHARED
${CUSTOM_OPS_CPU_SRCS})
-target_link_libraries(caffe2_detectron_custom_ops caffe2_library)
+# static protobuf library
+add_library(libprotobuf STATIC IMPORTED)
+set(PROTOBUF_LIB "$ENV{VIRTUAL_ENV}/lib/python2.7/site-packages/torch/lib/libprotobuf.a")
+set_property(TARGET libprotobuf PROPERTY IMPORTED_LOCATION "${PROTOBUF_LIB}")
+
+target_link_libraries(caffe2_detectron_custom_ops caffe2_library libprotobuf)
install(TARGETS caffe2_detectron_custom_ops DESTINATION lib)
# Install custom GPU ops lib, if gpu is present.
@@ -47,6 +52,6 @@ if (CAFFE2_USE_CUDA OR CAFFE2_FOUND_CUDA)
${CUSTOM_OPS_CPU_SRCS}
${CUSTOM_OPS_GPU_SRCS})
- target_link_libraries(caffe2_detectron_custom_ops_gpu caffe2_gpu_library)
+ target_link_libraries(caffe2_detectron_custom_ops_gpu caffe2_gpu_library libprotobuf)
install(TARGETS caffe2_detectron_custom_ops_gpu DESTINATION lib)
endif() |
@hyounsamk Thank you so much! This has it working perfectly upon rebuilding densepose. The initial guide for compiling pytorch/caffe2 can be found here. I'm on Ubuntu 16.04, CUDA 8.0 and cuDNN 6. For anyone reading my diff --git a/CMakeLists.txt b/CMakeLists.txt
-target_link_libraries(caffe2_detectron_custom_ops caffe2_library)
+# static protobuf library
+ add_library(libprotobuf STATIC IMPORTED)
+ set(PROTOBUF_LIB "/home/memesupreme/Documents/caffe2-pytorch/build/lib/libprotobuf.a")
+ set_property(TARGET libprotobuf PROPERTY IMPORTED_LOCATION "${PROTOBUF_LIB}")
+
+target_link_libraries(caffe2_detectron_custom_ops caffe2_library libprotobuf)
install(TARGETS caffe2_detectron_custom_ops DESTINATION lib)
# Install custom GPU ops lib, if gpu is present.
@@ -47,6 +52,6 @@ if (CAFFE2_USE_CUDA OR CAFFE2_FOUND_CUDA)
${CUSTOM_OPS_CPU_SRCS}
${CUSTOM_OPS_GPU_SRCS})
- target_link_libraries(caffe2_detectron_custom_ops_gpu caffe2_gpu_library)
+ target_link_libraries(caffe2_detectron_custom_ops_gpu caffe2_gpu_library libprotobuf)
install(TARGETS caffe2_detectron_custom_ops_gpu DESTINATION lib)
endif() |
@ingramator @hyounsamk excuse me, my env location is
It'll raise "unexpected symbol error". |
@ingramator @hyounsamk I don't understand where to modify these command, could you please supply more details? |
@ingramator @hyounsamk I got this, we have to modify the Notes:
like @ingramator does, because |
Great fix @ingramator ! Saved my day! |
i have the same problem have you solved it? |
+1. Same problem after add
|
How are you meant to resolve this issue if you have installed caffe via the anaconda Pytorch installation? That version does not come with a libprotobuf.a (I've searched the entirety of my computer) I'm beginning to think projects need to start explicitly stating which version of protobuf they are using, because nowadays nearly every problem I encounter involves a mismatched protobuf version in some way! I have now gone through and tried several versions of protobuf: 3.5.0 and 3.5.1 are the only versions that seem to allow 'make ops' to compile. However, neither of those versions fix this issue about an undefined symbol. There's clearly something broken in the DensePose code. |
OSError: /home/ubuntu/densepose/build/libcaffe2_detectron_custom_ops_gpu.so: undefined symbol: _ZN6google8protobuf8internal10LogMessagelsEPKc |
All the steps are ok but I met an OSError when testing test_zero_even_op.py:
OSError: /home/xbliu/densepose/densepose/build/libcaffe2_detectron_custom_ops_gpu.so: undefined symbol: _ZN6google8protobuf8internal9ArenaImpl28AllocateAlignedAndAddCleanupEmPFvPvE .
I've tried to uninstall protobuf and reinstall it but still have this error. Please kindly help me where I can correct.
By the way, will this error stop me from referring an image? Currently, I just want to estimate the human pose in an image, not training the model. Can I do this with this error? Thank you very much.
The text was updated successfully, but these errors were encountered: