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: #48

Closed
krebsm249 opened this issue Jul 11, 2018 · 31 comments
Closed

Undefined symbol: #48

krebsm249 opened this issue Jul 11, 2018 · 31 comments

Comments

@krebsm249
Copy link

Hello, I am trying to run: python train.py. I get the the following error

-workstation:~/pointnet2$ python train.py
/usr/local/lib/python2.7/dist-packages/h5py/init.py:36: FutureWarning: Conversion of the second argument of issubdtype from float to np.floating is deprecated. In future, it will be treated as np.float64 == np.dtype(float).type.
from ._conv import register_converters as _register_converters
Traceback (most recent call last):
File "train.py", line 52, in
MODEL = importlib.import_module(FLAGS.model) # import network module
File "/usr/lib/python2.7/importlib/init.py", line 37, in import_module
import(name)
File "/home/baxter/pointnet2/models/pointnet2_cls_ssg.py", line 13, in
from pointnet_util import pointnet_sa_module
File "/home/baxter/pointnet2/utils/pointnet_util.py", line 15, in
from tf_sampling import farthest_point_sample, gather_point
File "/home/baxter/pointnet2/tf_ops/sampling/tf_sampling.py", line 12, in
sampling_module=tf.load_op_library(os.path.join(BASE_DIR, 'tf_sampling_so.so'))
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/load_library.py", line 56, in load_op_library
lib_handle = py_tf.TF_LoadLibrary(library_filename, status)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/errors_impl.py", line 473, in exit
c_api.TF_GetCode(self.status.status))
tensorflow.python.framework.errors_impl.NotFoundError: /home/baxter/pointnet2/tf_ops/sampling/tf_sampling_so.so: undefined symbol: _ZTIN10tensorflow8OpKernelE

@julianstolp
Copy link

julianstolp commented Jul 12, 2018

I had the same problem after compiling the custom tf ops. The solution for me was to do not use the parameter "-D_GLIBCXX_USE_CXX11_ABI=0"
I'm using Tensorflow 1.8 on Ubuntu 16.04 with CUDA 9.2 and Python 3.5

#/bin/bash
CUDA_ROOT=/usr/local/cuda-9.2
TF_ROOT=/home/user/.local/lib/python3.5/site-packages/tensorflow
/usr/local/cuda-9.2/bin/nvcc -std=c++11 -c -o tf_sampling_g.cu.o tf_sampling_g.cu -O2 -DGOOGLE_CUDA=1 -x cu -Xcompiler -fPIC
#TF 1.8
g++ -std=c++11 tf_sampling.cpp tf_sampling_g.cu.o -o tf_sampling_so.so -shared -fPIC -I ${TF_ROOT}/include -I ${CUDA_ROOT}/include -I ${TF_ROOT}/include/external/nsync/public -lcudart -L ${CUDA_ROOT}/lib64/ -L ${TF_ROOT} -ltensorflow_framework -O2 #-D_GLIBCXX_USE_CXX11_ABI=0

This is the script i used for compiling. Hope it helps.

In general if you compiled Tensorflow from source with gcc Version >4 you dont need the option -D_GLIBCXX_USE_CXX11_ABI=0.
As it is stated in https://www.tensorflow.org/install/source

The official TensorFlow packages are built with GCC 4 and use the older ABI. For GCC 5 and later, make your build compatible with the older ABI using: --cxxopt="-D_GLIBCXX_USE_CXX11_ABI=0". ABI compatibility ensures that custom ops built against the official TensorFlow package continue to work with the GCC 5 built package.

@NicksonYap
Copy link

I'm using GCC 5.4.0, bu somehow had to include -D_GLIBCXX_USE_CXX11_ABI=0

TF 1.12.0, CUDA 9.0

The below code is following the guidelines from the readme

#/bin/bash
CUDA_ROOT=/usr/local/cuda-9.0
TF_INC=$(python -c 'import tensorflow as tf; print(tf.sysconfig.get_include())')
TF_LIB=$(python -c 'import tensorflow as tf; print(tf.sysconfig.get_lib())')

echo $CUDA_ROOT
echo $TF_INC
echo $TF_LIB

$CUDA_ROOT/bin/nvcc tf_sampling_g.cu -o tf_sampling_g.cu.o -c -O2 -DGOOGLE_CUDA=1 -x cu -Xcompiler -fPIC

# TF>=1.4.0
g++ -std=c++11 tf_sampling.cpp tf_sampling_g.cu.o -o tf_sampling_so.so -shared -fPIC -I$TF_INC/ -I$TF_INC/external/nsync/public -L$TF_LIB -ltensorflow_framework -I$CUDA_ROOT/include -lcudart -L$CUDA_ROOT/lib64/ -O2 -D_GLIBCXX_USE_CXX11_ABI=0

@SalaheddineSTA
Copy link

Hello,
I'm using TF-gpu 1.13.0 and Cuda10.0 on Ubuntu 18.04 and i still have this problem when i run train.py.
is this problem being produced because of TF and Cuda version ?
PS : I couldn't use Cuda 9.0 on my Ubuntu version because of g++ version (> 6.0).

@lqzhao
Copy link

lqzhao commented May 25, 2019

Hello,
I'm using TF-gpu 1.13.0 and Cuda10.0 on Ubuntu 18.04 and i still have this problem when i run train.py.
is this problem being produced because of TF and Cuda version ?
PS : I couldn't use Cuda 9.0 on my Ubuntu version because of g++ version (> 6.0).

Hello, the configuration of my computer is the same as yours. Have you solved this problem yet?

@usherbob
Copy link

@lqzhao You should try the way mentioned by Bierfass. We have the same environments, and I made it work in that way.

@chrmor
Copy link

chrmor commented Jun 12, 2019

Hi, I had the same problem.
using TF-gpu 1.13.1 and Cuda10.1 on Ubuntu 16.04 (I'm using the nvidia tensorflow docker).
The solution posted by @NicksonYap seems to work for me! Thank you so much :-)

@lqzhao
Copy link

lqzhao commented Jun 13, 2019

@lqzhao You should try the way mentioned by Bierfass. We have the same environments, and I made it work in that way.

Thanks for your enthusiastic reply, I‘ve solved this problem.

@pournami123
Copy link

I am using GCC 4.8.5 with TF-gpu 1.13.0 and Cuda10.0 on Centos7. I followed the steps given by @NicksonYap . But I am getting the error of
/pointnet2/tf_ops/sampling/tf_sampling_so.so: undefined symbol: _ZN10tensorflow8internal21CheckOpMessageBuilder9NewStringEv
Please help me.

@MrCrazyCrab
Copy link

@pournami123 have you solve it ? i met the same problem as you when i run tensorlfow1.13.1, but it can work at tensorflow 1.9.0.

@pournami123
Copy link

oh is it? Ok... I couldn't solve the problem with my tensorflow version.

@pauloffsf
Copy link

Besides taking the "-D_GLIBCXX_USE_CXX11_ABI=0" parameter of the g++, I got to fix my problem with this:

you need to see if the -ltensorflow_framework was linked properlly in your tf_ops *.so. For that, use:

$ldd tf_grouping_so.so (for example)

check if the libtensorflow_framework.so is in the list (2). If it isn't, you haven't linked it properly (1).

  1. This may happen if your library is in another version, and it is something like *.so.x, where x is a number of the version. If this is the case, you need to create a symbolic link from a *.so to *.so.x:

$sudo ln -s libtensorflow_framework.so.x libtensorflow_framework.so
You then, have to compile every tf_op again, and try checking the ldd again.

  1. If it is in the list, but it checks as not found, you just need to add its path to the ld library path:
    $export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:(path to were libtensorflow_framework.so is)
    $sudo ldconfig

That's it.

you can check again with ldd to see if the library is there in the list and being properly found. and run your train.py

I was able to solve it in an anaconda python 3.7, with g++ 7.5, tensorflow 2.1

@CaineGu
Copy link

CaineGu commented Jun 14, 2020

Hello,
I'm using TF-gpu 1.13.0 and Cuda10.0 on Ubuntu 18.04 and i still have this problem when i run train.py.
is this problem being produced because of TF and Cuda version ?
PS : I couldn't use Cuda 9.0 on my Ubuntu version because of g++ version (> 6.0).

can you fix tihs problem yet? I have similar env with urs

@SalaheddineSTA
Copy link

Hello,
I'm using TF-gpu 1.13.0 and Cuda10.0 on Ubuntu 18.04 and i still have this problem when i run train.py.
is this problem being produced because of TF and Cuda version ?
PS : I couldn't use Cuda 9.0 on my Ubuntu version because of g++ version (> 6.0).

can you fix tihs problem yet? I have similar env with urs

Hello @CaineGu , No i didn't fix it yet :(

@CaineGu
Copy link

CaineGu commented Jun 15, 2020

Besides taking the "-D_GLIBCXX_USE_CXX11_ABI=0" parameter of the g++, I got to fix my problem with this:

you need to see if the -ltensorflow_framework was linked properlly in your tf_ops *.so. For that, use:

$ldd tf_grouping_so.so (for example)

check if the libtensorflow_framework.so is in the list (2). If it isn't, you haven't linked it properly (1).

1. This may happen if your library is in another version, and it is something like *.so.x, where x is a number of the version. If this is the case, you need to create a symbolic link from a *.so to *.so.x:

$sudo ln -s libtensorflow_framework.so.x libtensorflow_framework.so
You then, have to compile every tf_op again, and try checking the ldd again.

1. If it is in the list, but it checks as not found, you just need to add its path to the ld library path:
   $export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:(path to were libtensorflow_framework.so is)
   $sudo ldconfig

That's it.

you can check again with ldd to see if the library is there in the list and being properly found. and run your train.py

I was able to solve it in an anaconda python 3.7, with g++ 7.5, tensorflow 2.1

Could you please tell me how to check f the -ltensorflow_framework was linked properlly? I have a similar env with you

@pauloffsf
Copy link

Well, in my text i said how you can check it... just use "ldd" in the tf_ops you are trying to compile.

@RyanHangZhou
Copy link

Hello,
I'm using TF-gpu 1.13.0 and Cuda10.0 on Ubuntu 18.04 and i still have this problem when i run train.py.
is this problem being produced because of TF and Cuda version ?
PS : I couldn't use Cuda 9.0 on my Ubuntu version because of g++ version (> 6.0).

I met the same problem. On Ubuntu 18.04, how to deploy the setting? Still meet the same error.

@RyanHangZhou
Copy link

Hello,
I'm using TF-gpu 1.13.0 and Cuda10.0 on Ubuntu 18.04 and i still have this problem when i run train.py.
is this problem being produced because of TF and Cuda version ?
PS : I couldn't use Cuda 9.0 on my Ubuntu version because of g++ version (> 6.0).

can you fix tihs problem yet? I have similar env with urs

Hello @CaineGu , No i didn't fix it yet :(

I met the same problem as well. Have you fixed it?

@vajrag
Copy link

vajrag commented Sep 12, 2020

Besides taking the "-D_GLIBCXX_USE_CXX11_ABI=0" parameter of the g++, I got to fix my problem with this:

you need to see if the -ltensorflow_framework was linked properlly in your tf_ops *.so. For that, use:

$ldd tf_grouping_so.so (for example)

check if the libtensorflow_framework.so is in the list (2). If it isn't, you haven't linked it properly (1).

  1. This may happen if your library is in another version, and it is something like *.so.x, where x is a number of the version. If this is the case, you need to create a symbolic link from a *.so to *.so.x:

$sudo ln -s libtensorflow_framework.so.x libtensorflow_framework.so
You then, have to compile every tf_op again, and try checking the ldd again.

  1. If it is in the list, but it checks as not found, you just need to add its path to the ld library path:
    $export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:(path to were libtensorflow_framework.so is)
    $sudo ldconfig

That's it.

you can check again with ldd to see if the library is there in the list and being properly found. and run your train.py

I was able to solve it in an anaconda python 3.7, with g++ 7.5, tensorflow 2.1

@pauloffsf This solution worked for me. Thank you
I am using Tensorflow-GPU 1.14, Cuda version- 10.0, g++ 5.5 and Python 3.6. Also, I didn't comment this flag -D_GLIBCXX_USE_CXX11_ABI=0

@gvalvano
Copy link

gvalvano commented Sep 26, 2020

Besides taking the "-D_GLIBCXX_USE_CXX11_ABI=0" parameter of the g++, I got to fix my problem with this:
you need to see if the -ltensorflow_framework was linked properlly in your tf_ops *.so. For that, use:
$ldd tf_grouping_so.so (for example)
check if the libtensorflow_framework.so is in the list (2). If it isn't, you haven't linked it properly (1).

  1. This may happen if your library is in another version, and it is something like *.so.x, where x is a number of the version. If this is the case, you need to create a symbolic link from a *.so to *.so.x:

$sudo ln -s libtensorflow_framework.so.x libtensorflow_framework.so
You then, have to compile every tf_op again, and try checking the ldd again.

  1. If it is in the list, but it checks as not found, you just need to add its path to the ld library path:
    $export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:(path to were libtensorflow_framework.so is)
    $sudo ldconfig

That's it.
you can check again with ldd to see if the library is there in the list and being properly found. and run your train.py
I was able to solve it in an anaconda python 3.7, with g++ 7.5, tensorflow 2.1

@pauloffsf This solution worked for me. Thank you
I am using Tensorflow-GPU 1.14, Cuda version- 10.0, g++ 5.5 and Python 3.6. Also, I didn't comment this flag -D_GLIBCXX_USE_CXX11_ABI=0

Hello everyone :) thanks for posting this.

@vajrag I have the same configuration as you: g++ 5.5 and Python 3.6, Tensorflow-GPU 1.14 (but I have Cuda version- 10.2). Maybe I did not get how to solve the problem, but I still get the error:

tensorflow.python.framework.errors_impl.NotFoundError: /path/to/filename/high_dim_filter.so: undefined symbol: _ZTIN10tensorflow8OpKernelE

I've tried to go in the path: /path/to/filename/ and run ldd high_dim_filter.so, which gives me:

linux-vdso.so.1 (0x00007ffd0e948000)
libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007fcc7507b000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fcc74cdd000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007fcc74ac5000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fcc746d4000)
/lib64/ld-linux-x86-64.so.2 (0x00007fcc75659000)

So neither libtensorflow_framework.so, nor libtensorflow_framework.so.x is listed here. What did I miss?

@vajrag
Copy link

vajrag commented Sep 27, 2020

Hi @gvalvano, libtensorflow_framework.so.1 is not on the list. You can follow step 1 from @pauloffsf 's solution. And I have commented the -D_GLIBCXX_USE_CXX11_ABI=0 flag

  1. sudo ln -s libtensorflow_framework.so.x libtensorflow_framework.so
  2. Compile the .sh files and check if it is on the list again using ldd xxx.so

@gvalvano
Copy link

Hi @gvalvano, libtensorflow_framework.so.1 is not on the list. You can follow step 1 from @pauloffsf 's solution. And I have commented the -D_GLIBCXX_USE_CXX11_ABI=0 flag

  1. sudo ln -s libtensorflow_framework.so.x libtensorflow_framework.so
  2. Compile the .sh files and check if it is on the list again using ldd xxx.so

Thank you for your help :) I've tried doing it, but it seems that running (1) has no effect on the output of (2). These are the exact commands I ran (I just copy-paste them below):

sudo ln -s libtensorflow_framework.so.x libtensorflow_framework.so
make
ldd high_dim_filter.so

and the last command still gives me:

linux-vdso.so.1 (0x00007fffe1ba7000)
libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007fc423853000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fc4234b5000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007fc42329d000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fc422eac000)
/lib64/ld-linux-x86-64.so.2 (0x00007fc423e31000)

In the folder, I have a Makefile with the following content:

# Define the compiler
CC := g++-5

# Read Tensorflow paths
TF_INC := $(shell python -c 'import tensorflow as tf; print(tf.sysconfig.get_include())')
TF_LIB := $(shell python -c 'import tensorflow as tf; print(tf.sysconfig.get_lib())')

# 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)

# Flags required for all cases
CFLAGS := -std=c++11 -shared -fPIC -I$(TF_INC) -O2  # -D_GLIBCXX_USE_CXX11_ABI=0

# Set a special flag if we are on macOS
ifeq ($(shell uname -s), Darwin)
        CFLAGS += -undefined dynamic_lookup
endif

# Set some more flags if the Tensorflow version is >= 1.4
ifeq ($(TF_VERSION_GTE_1_4), 1)
    CFLAGS += -I$(TF_INC)/external/nsync/public
        LDFLAGS := -L$(TF_LIB) -ltensorflow_framework
else
        LDFLAGS :=
endif

# Define build targets
.PHONY: all clean

high_dim_filter.so: high_dim_filter.cc modified_permutohedral.cc
        $(CC) $(CFLAGS) -o high_dim_filter.so high_dim_filter.cc modified_permutohedral.cc $(LDFLAGS)

clean:
        $(RM) high_dim_filter.so

all: high_dim_filter.so

I did not write the above code, so I'm not totally sure of what it does. My tensorflow version is 1.14.0, so TF_VERSION_GTE_1_4 should evaluate to True. The script runs on Ubuntu 18.04.

Thanks a lot for helping me with this :) :)

@pauloffsf
Copy link

@gvalvano hi!
I saw the command you are using to create the symbolic link to the tensorflow lib, and you aren't putting the tensorflow version instead of the x (as you said you are using the TF 1.14, probably yours is the libtensorflow_framework.so.1 . And also you need to do this command in the folder that the libtensorflow_framework.so.1 is.

After that, you go back to the folder your high_dim_filter.so is to compile it again, and then, check if the tensorflow lib is listed with ldd.

@gvalvano
Copy link

gvalvano commented Sep 27, 2020

@gvalvano hi!
I saw the command you are using to create the symbolic link to the tensorflow lib, and you aren't putting the tensorflow version instead of the x (as you said you are using the TF 1.14, probably yours is the libtensorflow_framework.so.1 . And also you need to do this command in the folder that the libtensorflow_framework.so.1 is.

After that, you go back to the folder your high_dim_filter.so is to compile it again, and then, check if the tensorflow lib is listed with ldd.

Thanks @pauloffsf, that's clearer now. But unfortunately, this still didn't solve my issue :(

I'm using a virtual environment named tf114. So, libtensorflow_framework.so.1 should be the one under:

/home/gabriele/venvs/conda/miniconda3/envs/tf114/lib/python3.7/site-packages/tensorflow

And, in fact, there it is!
My steps below:

source activate tf114
cd /home/gabriele/venvs/conda/miniconda3/envs/tf114/lib/python3.7/site-packages/tensorflow
sudo ln -s libtensorflow_framework.so.1 libtensorflow_framework.so

now I also have libtensorflow_framework.so. Then I go back to the directory with the Makefile to make the .so:

cd dir/where/there/is/high_dim_filter.so/
make
ldd high_dim_filter.so

but I still get:

linux-vdso.so.1 (0x00007fff45bdf000)
libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007fe689b99000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fe6897fb000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007fe6895e3000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fe6891f2000)
/lib64/ld-linux-x86-64.so.2 (0x00007fe68a177000)

I really don't understand the problem here :/

@pauloffsf
Copy link

pauloffsf commented Sep 27, 2020

Maybe the addresses that you are getting in the make file are not responding as they should in the terminal and so it is not linking the tensorflow lib properly.

Why dont you try compiling it with "hard" addresses first?

@gvalvano
Copy link

Maybe the addresses that you are getting in the make file are not responding as they should in the terminal and so it is not linking the tensorflow lib properly.

Why dont you try compiling it with "hard" addresses first?

Nice catch! That was one problem, indeed! But I have a new problem now 😅
I modified the Makefile as:

# Define the compiler
CC=/usr/bin/g++-5
# Read Tensorflow paths
TF_INC=/home/gabriele/venvs/conda/miniconda3/envs/tf114/lib/python3.7/site-packages/tensorflow/include
TF_LIB=/home/gabriele/venvs/conda/miniconda3/envs/tf114/lib/python3.7/site-packages/tensorflow
# Is the Tensorflow version >= 1.4?
TF_VERSION_GTE_1_4=1

After re-compiling, and ldd high_dim_filter.so, I get:

linux-vdso.so.1 (0x00007ffde0d5d000)
libtensorflow_framework.so.1 => not found
libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007efcf51dd000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007efcf4e3f000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007efcf4c27000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007efcf4836000)
/lib64/ld-linux-x86-64.so.2 (0x00007efcf57bb000)

Now, we have libtensorflow_framework.so.1 => not found, which is already a progress.

I have libtensorflow_framework.so.1 under /home/gabriele/venvs/conda/miniconda3/envs/tf114/lib/python3.7/site-packages/tensorflow together with the symbolic link I created to libtensorflow_framework.so.
However, I'm confused: why is it looking for libtensorflow_framework.so.1 rather than libtensorflow_framework.so? and why is it unable to find it?

Thanks a lot for you help 😁

@pauloffsf
Copy link

@gvalvano , so you have solved it... just check the second part of my solution (I copied it here):

"
If it is in the list, but it checks as not found, you just need to add its path to the ld library path:
$export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:(path to were libtensorflow_framework.so is)
$sudo ldconfig
"
So instead of the parenthesis part, you need to put "/home/gabriele/venvs/conda/miniconda3/envs/tf114/lib/python3.7/site-packages/tensorflow"

It is looking for libtensorflow_framework.so.1 because it is the lib it will use. The libtensorflow_framework.so created is just a symbolic link to it. We need the symbolic link because when we link a library with -lsomething (in this case ltensorflow_framework), it looks for libsomething.so ( libtensorflow_framework.so for us).

@gvalvano
Copy link

@pauloffsf thanks, that solved the issue with the linking! 😁 😁

As @vajrag , I also had to comment the -D_GLIBCXX_USE_CXX11_ABI=0 flag to make it work during the import in tensorflow. Thank you both guys ⭐️

@piseabhijeet
Copy link

Hi,

I am using TF 1.15.3 and a forked version of this model https://github.com/irfan798/pointnet2/tree/master.
And i can successfully compile the tf_xxx_compile.sh using solution from #48 (comment) and linking libtensorflow_framework.so.1 to libtensorflow_framework.so.

@VMohinder
Copy link

Similar problem

tf_sampling_so.so: undefined symbol: _ZN10tensorflow8internal21CheckOpMessageBuilder9NewStringEv

Configuration

python 2.7
gcc/g++ 4.8.5
TF 1.12.0
cuda 9

Compilation

CUDA_ROOT=/usr/local/cuda-9.0/
TF_ROOT=/home/bizon/anaconda3/envs/tf120py27/lib/python2.7/site-packages/tensorflow/

${CUDA_ROOT}bin/nvcc tf_sampling_g.cu -o tf_sampling_g.cu.o -c -O2 -DGOOGLE_CUDA=1 -x cu -Xcompiler -fPIC

g++ -std=c++11 tf_sampling.cpp tf_sampling_g.cu.o -o tf_sampling_so.so -shared -fPIC -I ${TF_ROOT}/include -I ${CUDA_ROOT}/include -lcudart -L ${CUDA_ROOT}/lib64/ -L ${TF_ROOT} -ltensorflow_framework -O2 -D_GLIBCXX_USE_CXX11_ABI=0

and

CUDA_ROOT=/usr/local/cuda-9.0/
TF_ROOT=/home/bizon/anaconda3/envs/tf120py27/lib/python2.7/site-packages/tensorflow/

${CUDA_ROOT}bin/nvcc tf_grouping_g.cu -o tf_grouping_g.cu.o -c -O2 -DGOOGLE_CUDA=1 -x cu -Xcompiler -fPIC

g++ -std=c++11 tf_grouping.cpp tf_grouping_g.cu.o -o tf_grouping_so.so -shared -fPIC -I ${TF_ROOT}/include -I ${CUDA_ROOT}/include -lcudart -L ${CUDA_ROOT}/lib64/ -L ${TF_ROOT} -ltensorflow_framework -O2 -D_GLIBCXX_USE_CXX11_ABI=0

@lihanxing
Copy link

I had the same problem after compiling the custom tf ops. The solution for me was to do not use the parameter "-D_GLIBCXX_USE_CXX11_ABI=0" I'm using Tensorflow 1.8 on Ubuntu 16.04 with CUDA 9.2 and Python 3.5

#/bin/bash CUDA_ROOT=/usr/local/cuda-9.2 TF_ROOT=/home/user/.local/lib/python3.5/site-packages/tensorflow /usr/local/cuda-9.2/bin/nvcc -std=c++11 -c -o tf_sampling_g.cu.o tf_sampling_g.cu -O2 -DGOOGLE_CUDA=1 -x cu -Xcompiler -fPIC #TF 1.8 g++ -std=c++11 tf_sampling.cpp tf_sampling_g.cu.o -o tf_sampling_so.so -shared -fPIC -I ${TF_ROOT}/include -I ${CUDA_ROOT}/include -I ${TF_ROOT}/include/external/nsync/public -lcudart -L ${CUDA_ROOT}/lib64/ -L ${TF_ROOT} -ltensorflow_framework -O2 #-D_GLIBCXX_USE_CXX11_ABI=0

This is the script i used for compiling. Hope it helps.

In general if you compiled Tensorflow from source with gcc Version >4 you dont need the option -D_GLIBCXX_USE_CXX11_ABI=0. As it is stated in https://www.tensorflow.org/install/source

The official TensorFlow packages are built with GCC 4 and use the older ABI. For GCC 5 and later, make your build compatible with the older ABI using: --cxxopt="-D_GLIBCXX_USE_CXX11_ABI=0". ABI compatibility ensures that custom ops built against the official TensorFlow package continue to work with the GCC 5 built package.

wonderful!

@pratibhashinde
Copy link

pratibhashinde commented Feb 10, 2022

I am still getting the same error: tensorflow.pythn.framework.errors_iml.notfounderror. undefined symbol:_ZTIN10tensorflow8OpKernelE.

I referred the comment given by pauloffsf and checked with ldd tf_grouping_so.so. and it doesnt show any tensorflow linked. When I tried to use sudo, It asking for the permission. I am using my university laptop for working on this code and I think, I dont have access to run sudo commnds.

commenting: "-D_GLIBCXX_USE_CXX11_ABI=0" doesnt work for me.

What shall I do now ? Please someone help.

Thanks.

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