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

roi_pooling.so Makefile #12

Open
symechar opened this issue Dec 31, 2018 · 1 comment
Open

roi_pooling.so Makefile #12

symechar opened this issue Dec 31, 2018 · 1 comment

Comments

@symechar
Copy link

Hello, i get the following error: tensorflow.python.framework.errors_impl.NotFoundError: ~/nms_net/roi_pooling_layer/roi_pooling.so: undefined symbol: _ZN10tensorflow7strings6StrCatB5cxx11ERKNS0_8AlphaNumE Is there any advice solving it?

@SchroeterJulien
Copy link

Hi,

While this will certainly be too late for the original author of the question, here is what worked for me (Tensorflow 1.14). Disclaimer: I mostly don't know what I am doing, so if you are a real and rigorous programmer apologies in advance. But at least the following worked for me, thus it might help others out:

  1. In Makefile, add -D_GLIBCXX_USE_CXX11_ABI=0 to each g++ command. This might already fix it for some. [1] [2]

  2. In Makefile, add -L$TF_LIB -ltensorflow_framework to each g++ command, where TF_LIB=$(python -c 'import tensorflow as tf; print(tf.sysconfig.get_lib())') (this need to be added in the first lines). [3] [4] [5]. Depending on how you set things up on your computer, you might need to replace python with python3.

  3. Check manually that you have a file called libtensorflow_framework.so in $TF_LIB (see point 2. on how to obtain that path). If not, you should have a file that is almost called like it (e.g., libtensorflow_framework.so.1). In that case, you need to create a symbolic link [6]:

$ cd [$TF_LIB]
$ ln -s libtensorflow_framework.so.1 libtensorflow_framework.so
  1. In Makefile, add -lcudart -L $CUDA_PATH/lib64 to each g++ command, where CUDA_PATH=/usr/local/cuda/ (this need to be added in the first lines). To locate where cuda was installed on your machine (e.g., it might be /usr/local/cuda-10.0/) check [6]

At that point, it should be working. But if for some reason it is not, you might still try one last trick while you are at it: replace every variable containing a path (e.g., "L$TF_LIB") with a "fixed text" (e.g., -L/home/julien/.local/lib/python3.6/site-packages/tensorflow). In the end here is the version that worked for me (it is not pretty, but does the job):

TF_INC="/home/julien/.local/lib/python3.6/site-packages/tensorflow/include/" #$(python3 -c 'import tensorflow as tf; print(tf.sysconfig.get_include())')
TF_LIB="/home/julien/.local/lib/python3.6/site-packages/tensorflow" #$(python3 -c 'import tensorflow as tf; print(tf.sysconfig.get_lib())')

.PHONY: all

all: nms_net/matching_module/det_matching.so nms_net/roi_pooling_layer/roi_pooling.so imdb/file_formats/AnnoList_pb2.py

nms_net/roi_pooling_layer/roi_pooling.so: nms_net/roi_pooling_layer/roi_pooling_op.o nms_net/roi_pooling_layer/roi_pooling_op_gpu.o
	g++ -std=c++11 -shared $^ -o $@ -fPIC -O2 -lcudart -L/usr/local/cuda-10.0/lib64 -D_GLIBCXX_USE_CXX11_ABI=0 -L/home/julien/.local/lib/python3.6/site-packages/tensorflow -ltensorflow_framework

%.o: %.cc
	g++ -std=c++11 -c $< -o $@ -fPIC -I ${TF_INC} -O2 -lcudart -L/usr/local/cuda-10.0/lib64 -D_GLIBCXX_USE_CXX11_ABI=0 -L/home/julien/.local/lib/python3.6/site-packages/tensorflow -ltensorflow_framework

%.o: %.cu
	nvcc -std=c++11 -c $< -o $@ -I ${TF_INC} -O2 -x cu -arch=sm_35 -D GOOGLE_CUDA=1 -Xcompiler -fPIC

%.so: %.cc
	g++ -std=c++11 -shared $< -o $@ -fPIC -I ${TF_INC} -O2 -lcudart -L/usr/local/cuda-10.0/lib64 -D_GLIBCXX_USE_CXX11_ABI=0 -L/home/julien/.local/lib/python3.6/site-packages/tensorflow -ltensorflow_framework

%_pb2.py: %.proto
	protoc --python_out=. $<

Hope that these loose instructions will help someone.

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