sampepose / flownet2-tf

FlowNet 2.0: Evolution of Optical Flow Estimation with Deep Networks
MIT License
404 stars 195 forks source link

undefined symbol: _ZN10tensorflow12OpDefBuilder4AttrESs #102

Open yrj88351 opened 5 years ago

yrj88351 commented 5 years ago

Firstly, after I finished the compile with adding the "-NDEBUG " to CFLAGS , i meet the problem " xxxxxxx/correlation.so: undefined symbol: _ZTIN10tensorflow8OpKernelE****" when i want to run the Inference.

Then i add the " TF_LIB = python -c "import tensorflow; print(tensorflow.sysconfig.get_lib())" at the begining of Makefile and " -L $(TF_LIB) -ltensorflow_framework" to CGPUFLAGS . This time it is reported that " xxxxxxx/correlation.so: undefined symbol: _ZN10tensorflow12OpDefBuilder4AttrESs " when i want to run the inference.

Now i have no idea how to solve this ..... Really need your help !!!

My Context: CUDA: 10.0 Tensorflow: 1.13 g++: 5.4 ubuntu: 16.04

yrj88351 commented 5 years ago

And when i use the command "ldd -r correlation.so ", i found that there are so many undefined symbol

gustavla commented 4 years ago

It's not linking against TF. I modified the Makefile as follows to get around it (asking TF what appropriate linking flags to add):

diff --git a/Makefile b/Makefile
index 073c011..202236b 100644
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,7 @@
 # Makefile

-TF_INC = `python -c "import tensorflow; print(tensorflow.sysconfig.get_include())"`
+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()))'`

 ifndef CUDA_HOME
     CUDA_HOME := /usr/local/cuda
@@ -9,9 +10,9 @@ endif
 CC        = gcc -O2 -pthread
 CXX       = g++
 GPUCC     = nvcc
-CFLAGS    = -std=c++11 -I$(TF_INC) -I"$(CUDA_HOME)/include" -DGOOGLE_CUDA=1
+CFLAGS    = -std=c++11 $(TF_CFLAGS) -I"$(CUDA_HOME)/include" -I"$(CUDA_HOME)/.." -DGOOGLE_CUDA=1
 GPUCFLAGS = -c
-LFLAGS    = -pthread -shared -fPIC
+LFLAGS    = -pthread -shared -fPIC $(TF_LFLAGS)
 GPULFLAGS = -x cu -Xcompiler -fPIC
 CGPUFLAGS = -L$(CUDA_HOME)/lib -L$(CUDA_HOME)/lib64 -lcudart

@@ -59,23 +60,23 @@ endif