When I tried to compile mxnet from sources, I encountered a linking error showing /usr/bin/ld: cannot find -lcuda.
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
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
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
I tried some suggestions in previous issues related to linking errors, the no find error kept occurring.
@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
Most helpful comment
you are missing libcuda.so symlink to libcuda.so.1
I do not know why is that but I think
will fix your problem.