Incubator-mxnet: errors in linking stage: cannot find -lcuda

Created on 26 Oct 2017  路  5Comments  路  Source: apache/incubator-mxnet

Description

When I tried to compile mxnet from sources, I encountered a linking error showing /usr/bin/ld: cannot find -lcuda.

Environment info (Required)

I have installed cuda-8.0 and cudnn-5.1 for cuda8.0 successfully. Tensorflow and torch run well on this computer. And the OS is ubuntu-16.04

some environment variables:

echo $LD_LIBRARY_PATH
/usr/local/cuda/lib64:/usr/local/cudnn5.1/lib64

Build info (Required if built from source)

Compiler (gcc/clang/mingw/visual studio):
I have tried gcc-4.8 and gcc-5.4.0, both of them have this error.

MXNet commit hash:
1df79b48a7fdb8920c4b73f728c05014101ffb3d

Build config:
I used this command to compile:
make -j $(nproc) USE_OPENCV=1 USE_BLAS=openblas USE_CUDA=1 USE_CUDA_PATH=/usr/local/cuda USE_CUDNN=1

I also add two lines in config.mk

ADD_LDFLAGS += -L/usr/local/cuda/lib64
ADD_LDFLAGS += -L/usr/local/cuda/cudnn5.1/lib64

Error Message:

titching -lopencv_superres -lopencv_video -lopencv_videostab -lcufft -lcublas -lnpps -lnppi -lnppc -lcudart -latomic -ltbb -lGL -lGLU -lrt -lpthread -lm -ldl -llapack -lcudnn -L/usr/local/cuda/lib64 -L/usr/local/cuda/cudnn5.1/lib64 -lcuda -lcufft -lnvrtc
/usr/bin/ld: cannot find -lcuda
collect2: error: ld returned 1 exit status
Makefile:384: recipe for target 'lib/libmxnet.so' failed
make: *** [lib/libmxnet.so] Error 1
make: *** Waiting for unfinished jobs....
/usr/bin/ld: cannot find -lcuda
collect2: error: ld returned 1 exit status
Makefile:406: recipe for target 'bin/im2rec' failed
make: *** [bin/im2rec] Error 1

What have you tried to solve it?

I tried some suggestions in previous issues related to linking errors, the no find error kept occurring.

Most helpful comment

you are missing libcuda.so symlink to libcuda.so.1
I do not know why is that but I think

sudo ln -s /usr/lib/x86_64-linux-gnu/libcuda.so.1 /usr/lib/x86_64-linux-gnu/libcuda.so

will fix your problem.

All 5 comments

@Beanocean find where libcuda.so.1 is in your box and have it in your LD_LIBRARY_PATH
libcuda.so.1 is from runtime cuda driver package
http://www.diegoacuna.me/installing-cuda-8-on-ubuntu-16-04/
the cuda driver is installed via
sudo apt-get install nvidia-367
You need the access to the driver for the ability of running cuda kernels created from python (or perl) space.

@sergeykolychev Thanks a lot for your reply. As you recommended, I added /usr/lib/x86_64-linux-gnu/ into LD_LIBRARY_PATH:

> $ locate libcuda.so                                                                                                                                                                                       
/usr/lib/x86_64-linux-gnu/libcuda.so.1
/usr/lib/x86_64-linux-gnu/libcuda.so.384.59
/usr/lib32/libcuda.so
/usr/lib32/libcuda.so.1
/usr/lib32/libcuda.so.384.59
/usr/local/cuda-8.0/doc/man/man7/libcuda.so.7
/usr/local/cuda-8.0/lib64/stubs/libcuda.so
/usr/share/man/man7/libcuda.so.7
>$ echo $LD_LIBRARY_PATH
/usr/lib/x86_64-linux-gnu:/usr/local/cuda/lib64:/usr/local/cudnn5.1/lib64

And added this ADD_LDFLAGS += -L/usr/lib/x86_64-linux-gnu/ to config.mk.
But this error still shows up:

-lcudnn -L/usr/local/cuda/lib64 -L/usr/local/cuda/cudnn5.1/lib64 -L/usr/lib/x86_64-linux-gnu -lcuda -lcufft -lnvrtc
/usr/bin/ld: cannot find -lcuda
collect2: error: ld returned 1 exit status
Makefile:384: recipe for target 'lib/libmxnet.so' failed
make: *** [lib/libmxnet.so] Error 1
make: *** Waiting for unfinished jobs....
/usr/bin/ld: cannot find -lcuda
collect2: error: ld returned 1 exit status
Makefile:406: recipe for target 'bin/im2rec' failed
make: *** [bin/im2rec] Error 1

Do you now how to check the installation of nvidia-dirver? I can use nvidia-smi and Tensorflow can use the GPUs in this box.

you are missing libcuda.so symlink to libcuda.so.1
I do not know why is that but I think

sudo ln -s /usr/lib/x86_64-linux-gnu/libcuda.so.1 /usr/lib/x86_64-linux-gnu/libcuda.so

will fix your problem.

@sergeykolychev I didn't notice this problem. Thanks for your remind and the problem was fixed.

I ran into the similar problem. Can you help me with it? Here are the Error Message:

/usr/bin/ld: cannot find -lnppi
collect2: error: ld returned 1 exit status
Makefile:466: recipe for target 'lib/libmxnet.so' failed
make: * [lib/libmxnet.so] Error 1
make:
Waiting for unfinished jobs....
/usr/bin/ld: cannot find -lnppi
collect2: error: ld returned 1 exit status
Makefile:495: recipe for target 'bin/im2rec' failed
make: *
* [bin/im2rec] Error 1

Was this page helpful?
0 / 5 - 0 ratings

Related issues

dmadeka picture dmadeka  路  3Comments

realbns2008 picture realbns2008  路  3Comments

ranti-iitg picture ranti-iitg  路  3Comments

dushoufu picture dushoufu  路  3Comments

Shiro-LK picture Shiro-LK  路  3Comments