Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

undefined symbol: _ZN10tensorflow12OpDefBuilder4AttrESs #102

Open
yrj88351 opened this issue Nov 1, 2019 · 2 comments
Open

undefined symbol: _ZN10tensorflow12OpDefBuilder4AttrESs #102

yrj88351 opened this issue Nov 1, 2019 · 2 comments

Comments

@yrj88351
Copy link

yrj88351 commented Nov 1, 2019

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
Copy link
Author

yrj88351 commented Nov 1, 2019

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

@gustavla
Copy link

gustavla commented Dec 29, 2019

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants