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

Error in compiling cuda code #28

Open
shahdev opened this issue Nov 3, 2020 · 7 comments
Open

Error in compiling cuda code #28

shahdev opened this issue Nov 3, 2020 · 7 comments

Comments

@shahdev
Copy link

shahdev commented Nov 3, 2020

I compiled the makefile succesfully

When I run python train_nn.py I get this error:
tensorflow.python.framework.errors_impl.NotFoundError: ./tf_nndistance_so.so: undefined symbol: _ZN10tensorflow12OpDefBuilder5InputESs

I am using a conda environment with python2.7, tensorflow 1.4 and gcc 4.8

This is my makefile:
nvcc = /usr/local/cuda-10.2/bin/nvcc
cudalib = /usr/local/cuda-10.2/lib64/
tensorflow = /home/dpshah2/.conda/envs/PSRNet/lib/python2.7/site-packages/tensorflow/include
tf_lib = /home/dpshah2/.conda/envs/PSRNet/lib/python2.7/site-packages/tensorflow

all: depthestimate/tf_nndistance_so.so depthestimate/render_balls_so.so
.PHONY : all

depthestimate/tf_nndistance_so.so: depthestimate/tf_nndistance_g.cu.o depthestimate/tf_nndistance.cpp
g++ -std=c++11 depthestimate/tf_nndistance.cpp depthestimate/tf_nndistance_g.cu.o -o depthestimate/tf_nndistance_so.so -shared -fPIC -I $(tensorflow) -ltensorflow_framework -L $(tf_lib) -O2 -D_GLIBCXX_USE_CXX11_ABI=0

depthestimate/tf_nndistance_g.cu.o: depthestimate/tf_nndistance_g.cu
$(nvcc) -D_GLIBCXX_USE_CXX11_ABI=0 -std=c++11 -c -o depthestimate/tf_nndistance_g.cu.o depthestimate/tf_nndistance_g.cu -I $(tensorflow) -DGOOGLE_CUDA=1 -x cu -Xcompiler -fPIC -O2

depthestimate/render_balls_so.so: depthestimate/render_balls_so.cpp
g++ -std=c++11 depthestimate/render_balls_so.cpp -o depthestimate/render_balls_so.so -shared -fPIC -O2 -D_GLIBCXX_USE_CXX11_ABI=0

@sbharadwajj
Copy link

I have the same issue. It would be great if someone who were able to successfully compile the cuda code post their environment details.

I am using: tensorflow 1.4.0, cuda: 8.0 and cudnn: 6

@justanhduc
Copy link

@shahdev @sbharadwajj I have successfully compiled with tf1.1 (downloaded with pip), cuda 8.0 and python 2.7.

@shahdev
Copy link
Author

shahdev commented Feb 16, 2021

@justanhduc can you share the makefile and how you managed to get it to work?

@justanhduc
Copy link

@shahdev I didn't do anything special besides fixing the CUDA path in the makefile. But I notice that I had to use a fresh clone to make it work, as I tried to compile with Python 3 but it failed, then I removed all the .so files and compiled again with Python 2 but it didn't work.
The make file is below

nvcc = ${CUDA_HOME}/bin/nvcc
cudalib = ${CUDA_HOME}/lib64/
tensorflow = ${HOME}/miniconda3/envs/py27/lib/python2.7/site-packages/tensorflow/include

all: depthestimate/tf_nndistance_so.so depthestimate/render_balls_so.so
.PHONY : all

depthestimate/tf_nndistance_so.so: depthestimate/tf_nndistance_g.cu.o depthestimate/tf_nndistance.cpp
	g++ -std=c++11 depthestimate/tf_nndistance.cpp depthestimate/tf_nndistance_g.cu.o -o depthestimate/tf_nndistance_so.so -shared -fPIC -I $(tensorflow) -lcudart -L $(cudalib) -O2 -D_GLIBCXX_USE_CXX11_ABI=0

depthestimate/tf_nndistance_g.cu.o: depthestimate/tf_nndistance_g.cu
	$(nvcc) -D_GLIBCXX_USE_CXX11_ABI=0 -std=c++11 -c -o depthestimate/tf_nndistance_g.cu.o depthestimate/tf_nndistance_g.cu -I $(tensorflow) -DGOOGLE_CUDA=1 -x cu -Xcompiler -fPIC -O2

depthestimate/render_balls_so.so: depthestimate/render_balls_so.cpp
	g++ -std=c++11 depthestimate/render_balls_so.cpp -o depthestimate/render_balls_so.so -shared -fPIC -O2 -D_GLIBCXX_USE_CXX11_ABI=0

@dwindy
Copy link

dwindy commented May 13, 2021

@shahdev I didn't do anything special besides fixing the CUDA path in the makefile. But I notice that I had to use a fresh clone to make it work, as I tried to compile with Python 3 but it failed, then I removed all the .so files and compiled again with Python 2 but it didn't work.
The make file is below

nvcc = ${CUDA_HOME}/bin/nvcc
cudalib = ${CUDA_HOME}/lib64/
tensorflow = ${HOME}/miniconda3/envs/py27/lib/python2.7/site-packages/tensorflow/include

all: depthestimate/tf_nndistance_so.so depthestimate/render_balls_so.so
.PHONY : all

depthestimate/tf_nndistance_so.so: depthestimate/tf_nndistance_g.cu.o depthestimate/tf_nndistance.cpp
	g++ -std=c++11 depthestimate/tf_nndistance.cpp depthestimate/tf_nndistance_g.cu.o -o depthestimate/tf_nndistance_so.so -shared -fPIC -I $(tensorflow) -lcudart -L $(cudalib) -O2 -D_GLIBCXX_USE_CXX11_ABI=0

depthestimate/tf_nndistance_g.cu.o: depthestimate/tf_nndistance_g.cu
	$(nvcc) -D_GLIBCXX_USE_CXX11_ABI=0 -std=c++11 -c -o depthestimate/tf_nndistance_g.cu.o depthestimate/tf_nndistance_g.cu -I $(tensorflow) -DGOOGLE_CUDA=1 -x cu -Xcompiler -fPIC -O2

depthestimate/render_balls_so.so: depthestimate/render_balls_so.cpp
	g++ -std=c++11 depthestimate/render_balls_so.cpp -o depthestimate/render_balls_so.so -shared -fPIC -O2 -D_GLIBCXX_USE_CXX11_ABI=0

Sorry for bothering you.
Could you explain what address the ${CUDA_HOME} stands for?
I am using anaconda, it seems the CUDA was not installed in /usr/local/cuda-x.x/bin/nvcc
But I am not sure where it is.
Thanks in advance

@justanhduc
Copy link

Hi @dwindy. You can check where your nvcc is using which nvcc in terminal. Then set ${CUDA_HOME} to be until the bin folder. Good luck!

@dwindy
Copy link

dwindy commented May 17, 2021

Hi @dwindy. You can check where your nvcc is using which nvcc in terminal. Then set ${CUDA_HOME} to be until the bin folder. Good luck!

Hi @justanhduc . Yes, I found it. Thank you!

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

4 participants