sadeepj / crfasrnn_keras

CRF-RNN Keras/Tensorflow version
http://crfasrnn.torr.vision
MIT License
603 stars 169 forks source link

Symbol not found: __ZN10tensorflow12OpDefBuilder4AttrESs #58

Closed qvandenberg closed 5 years ago

qvandenberg commented 5 years ago

Despite following instructions on similar issues, this error persists. Has anyone been able to resolve it so far?

python3 run_demo.py 
Using TensorFlow backend.
Traceback (most recent call last):
  File "run_demo.py", line 27, in <module>
    from crfrnn_model import get_crfrnn_model_def
  File "./src/crfrnn_model.py", line 28, in <module>
    from crfrnn_layer import CrfRnnLayer
  File "./src/crfrnn_layer.py", line 28, in <module>
    import high_dim_filter_loader
  File "./src/high_dim_filter_loader.py", line 28, in <module>
    custom_module = tf.load_op_library(os.path.join(os.path.dirname(__file__), 'cpp', 'high_dim_filter.so'))
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/tensorflow/python/framework/load_library.py", line 60, in load_op_library
    lib_handle = py_tf.TF_LoadLibrary(library_filename)
tensorflow.python.framework.errors_impl.NotFoundError: dlopen(./src/cpp/high_dim_filter.so, 6): Symbol not found: __ZN10tensorflow12OpDefBuilder4AttrESs
  Referenced from: ./src/cpp/high_dim_filter.so
  Expected in: flat namespace
in ./src/cpp/high_dim_filter.so
matthiasmace commented 5 years ago

Hi Q This is an error because arising because you copied highdimfilter in a python environment different from the one used for running the code. Why do you use python3 instead of python2.7 ? In either cas, you should do make under the virtualenv used to make run demo.py.

qvandenberg commented 5 years ago

Hi Matthias

I just changed my virtualenv to python2.7 and it produced the same error. I printed out the versions of all the other packages, that might hold some clues. requirements_q.txt

matthiasmace commented 5 years ago

Hi Q You have to "make clean" in the cpp folder et redo "make" under the same virtualenv you use for running python otherwise, tf won't load the new op. Did you do this ?

qvandenberg commented 5 years ago

Indeed, I was in the virtualenv while I used "make clean" to remove the .so file and compiled a new one. Unfortunately tf isn't able to locate the new op...

matthiasmace commented 5 years ago

Hi Q What is your platform ? Desktop or server ? Perhaps the same problem is pointed there : https://github.com/sadeepj/crfasrnn_keras/issues/35

qvandenberg commented 5 years ago

Hi Matthias, It occurs on two different machines (desktop & laptop). They're both OSX, one High Sierra and the other Mojave. I haven't tried on a server yet.

I just looked at issue #35 as suggested. There is a line that can cause trouble as tensorflow went beyond version 1.10. This expression in the makefile would no longer work, so I removed the related conditional statement.

# Is the Tensorflow version >= 1.4?
TF_VERSION_GTE_1_4 := $(shell expr `python -c 'import tensorflow as tf; print(tf.__version__)' | cut -f1,2 -d.` \>= 1.4)

That was unfortunately not enough to fix it.

matthiasmace commented 5 years ago

Hi Q, Did you fix your problem ? Trying this within the src/cpp/ folder ?

TF_CFLAGS=( $(python -c 'import tensorflow as tf; print(" ".join(tf.sysconfig.get_compile_flags()))') ) TF_LFLAGS=( $(python -c 'import tensorflow as tf; print(" ".join(tf.sysconfig.get_link_flags()))') )

g++ -std=c++11 -D_GLIBCXX_USE_CXX11_ABI=0 -shared -fPIC -I~/.virtualenvs/r-tensorflow/lib/python2.7/site-packages/tensorflow/include -O2 -o high_dim_filter.so high_dim_filter.cc modified_permutohedral.cc

qvandenberg commented 5 years ago

Unfortunately I've not been able to, also not with previous versions of tensorflow.

Running your command produces the error:

high_dim_filter.cc:25:42: fatal error: tensorflow/core/framework/op.h: No such file or directory
 #include "tensorflow/core/framework/op.h"

This is on a Mac, not a Linux.

matthiasmace commented 5 years ago

What about with TF version 1.2 ?

zhudelong commented 5 years ago

@qvandenberg Have you fixed that problem? I meet the same problem too. I tried several versions mentioned here, but none works.

qvandenberg commented 5 years ago

It's fixed now, thank you for your efforts. The problem turned out to be the C++ compiler. It worked only when I used C++ 4.2.1: Apple LLVM version 7.0.0 (clang-700.1.76)

It's stored under /usr/bin instead of /usr/local/bin where I keep most of my binaries. That caused the import problem.

zhudelong commented 5 years ago

@qvandenberg Got it! Thanks a lot!

skq-5233 commented 4 years ago

Hello! When I run the sh.compile.sh command, it compiles successfully, but when I run train.py, I get an error: undefined symbol:_ZTIN10tensorflow8opkernelE. I checked a lot of information on the Internet and did not solve it. Hope you help me see what is the problem. Thanks again! ! ! ubuntu :16.04 ; nvidia-driver-440;cuda:10.0; cudnn:7.5.0; tensorflow-gpu:1.13.1; gcc/g++:5.4.0; image

@matthiasmace