question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

/usr/bin/ld: cannot find -lcuda

See original GitHub issue

Hi all,

I don’t know if it is the issue but I don’t have root access so I install CUDA in my home directory. Then I added those paths to PATH and LD_LIBRARY_PATH:

export PATH="/my_local_path/cuda/bin:$PATH"
export LD_LIBRARY_PATH="/my_local_path/cuda/lib64:/my_local_path/cuda/lib:$LD_LIBRARY_PATH"
export CFLAGS=-I/my_local_path/cudnn/include
export LDFLAGS=-L/my_local_path/cudnn/lib64

I tried to install chainer from source and by pip install chainer --no-cache-dir -vvvv but they all failed to build with cuda:

Bellow are logs when I built chainer from source. Pip install outputs similar logs.

Options: {'profile': False, 'annotate': False, 'linetrace': False, 'no_cuda': False}
Include directories: ['/users/ud2017/hoavt/cuda/include']
Library directories: ['/users/ud2017/hoavt/cuda/lib64', '/users/ud2017/hoavt/cuda/lib']
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++ [enabled by default]
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++ [enabled by default]
/usr/bin/ld: cannot find -lcuda
collect2: error: ld returned 1 exit status
Cannot build a stub file.
Original error: command 'c++' failed with exit status 1
**************************************************
*** WARNING: Cannot link libraries: ['cublas', 'cuda', 'cudart', 'curand', 'nvToolsExt']
*** WARNING: Skip installing cuda support
*** WARNING: Check your LDFLAGS environment variable
**************************************************
Include directories: ['/users/ud2017/hoavt/cuda/include']
Library directories: ['/users/ud2017/hoavt/cuda/lib64', '/users/ud2017/hoavt/cuda/lib']
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++ [enabled by default]
/tmp/tmpHcwk2p/a.cpp:1:19: fatal error: cudnn.h: No such file or directory
 #include <cudnn.h>
                   ^
compilation terminated.
command 'x86_64-linux-gnu-gcc' failed with exit status 1
**************************************************
*** WARNING: Include files not found: ['cudnn.h']
*** WARNING: Skip installing cudnn support
*** WARNING: Check your CFLAGS environment variable
**************************************************
Include directories: ['/users/ud2017/hoavt/cuda/include']
Library directories: ['/users/ud2017/hoavt/cuda/lib64', '/users/ud2017/hoavt/cuda/lib']
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++ [enabled by default]
/tmp/tmpAvadWz/a.cpp:1:18: fatal error: nccl.h: No such file or directory
 #include <nccl.h>
                  ^
compilation terminated.
command 'x86_64-linux-gnu-gcc' failed with exit status 1
**************************************************
*** WARNING: Include files not found: ['nccl.h']
*** WARNING: Skip installing nccl support
*** WARNING: Check your CFLAGS environment variable
**************************************************
Include directories: ['/users/ud2017/hoavt/cuda/include']
Library directories: ['/users/ud2017/hoavt/cuda/lib64', '/users/ud2017/hoavt/cuda/lib']
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++ [enabled by default]
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++ [enabled by default]
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++ [enabled by default]
running instal

It took me two days to fix this issue without any success. I would really appreciate any suggestion. I want to use chainer for my project but without cuda support, it is quite slow.

OS: Ubuntu 14.04 gcc 4.8.4 python 2.7.6 Cuda compilation tools, release 7.0, V7.0.27 cudnn:

define CUDNN_MAJOR 4 define CUDNN_MINOR 0 define CUDNN_PATCHLEVEL 7

define CUDNN_VERSION (CUDNN_MAJOR * 1000 + CUDNN_MINOR * 100 + CUDNN_PATCHLEVEL)

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
Paosdercommented, May 30, 2017

@hoavt-54, did you put -I or -L characters in front of your cudnn environment variables? (LD_LIBRARY_PATH, CFLAGS…)

i.g.

export CFLAGS=-I/Developer/NVIDIA/CUDA-8.0/include
export LDFLAGS=-L/Developer/NVIDIA/CUDA-8.0/lib

Thank you @Paosder yes I did. I updated my first comment.

And you should also check that your cudnn path has -L characters(for lib directory). LD_LIBRARY_PATH=-L/Developer/NVIDIA/CUDA-8.0/lib:$LD_LIBRARY_PATH And you don’t have to put cuda path into LDFLAGS.

In my case, in MacOS, I put these characters so that I could fixed these link errors.

0reactions
unnonounocommented, May 31, 2017

No, usually a liker command uses $LIBRARY_PATH. $LD_LIBRARY_PATH is used only on runtime by dlopen system call. See http://man7.org/linux/man-pages/man3/dlopen.3.html

Read more comments on GitHub >

github_iconTop Results From Across the Web

cannot find -lcuda - CUDA Programming and Performance
I try compile deviceQuery, but when i do his return the error: make -C src/deviceQuery/ make[2]: Entering directory ...
Read more >
cannot find -lcuda when linking with g++
You need to add the compiler switch: -L/usr/local/cuda/lib64. or something similar, to tell g++ where to find the -lcuda and -lcudart ...
Read more >
usr/bin/ld : cannot find -lCUDA_cublas_device_LIBRARY- ...
I faced a similar problem when using LibTorch. What solved it for me was upgrading to CMake=3.15.2. I found this solution here: ...
Read more >
ld cannot find -lcuda, when compiling cuda programs
However, libcuda.so can be found under /usr/lib/nvidia-current. I'm using the 256.25 drivers from the X updates PPA, but according to reports on ...
Read more >
usr/bin/ld: cannot find -lcudart
/usr/bin/ld: cannot find -lcudart. cudanvcc ... bin/xspecfem3D ../. ... obj/spec/serial.o -lcuda -lcudart -lcublas. /usr/bin/ld: cannot find -lcudart.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found