Alex
Alex

Reputation: 503

Why can't libcudart.so.4 be found when compiling the CUDA samples under Ubuntu?

I'm trying to get my Cuda SDK samples running, but I get the following error:

./bandwidthTest: error while loading shared libraries:
                 libcudart.so.4: cannot open shared object file:
                 No such file or directory

Why can I compile the example successfully, but not run it? Is there a way to specify the path to the CUDA runtime library manually?

Upvotes: 27

Views: 40204

Answers (8)

user9869932
user9869932

Reputation: 7377

In my case I was running an application using MPI. The error was:

libcudart.so.7: cannot open shared object file

CUDA was properly installed in all nodes. Also, as in the previous answers, the variables $PATH and $LD_LIBRARY_PATH were pointing to the binary and libraries respectively.

Passing the $PATH and $LD_LIBRARY_PATH in the MPI command solved the issue.

mpirun -x PATH=$PATH -x LD_LIBRARY_PATH=$LD_LIBRARY_PATH ...

Upvotes: 0

dzhwinter
dzhwinter

Reputation: 49

the system find library with ld tool. as the top answer says, 64-bit: sudo ldconfig /usr/local/cuda-xx/lib64 ;;xx is the cuda libraryedition

Upvotes: 0

Jaime.Fernandez
Jaime.Fernandez

Reputation: 61

1 error while loading shared libraries: libcudart.so.6.0: cannot open shared object file: No such file or directory

  32-bit: sudo ldconfig /usr/local/cuda/lib

  64-bit: sudo ldconfig /usr/local/cuda/lib64

(refer: http://blog.csdn.net/shenchong721/article/details/21529295)

Works for me!

Upvotes: 6

sj755
sj755

Reputation: 4062

First these that you need is to concatenate the paths to the CUDA binaries and libraries. This is simply done by adding the following lines to your .bashrc file.

export PATH=$PATH:/usr/local/cuda/bin
export LD_LIBRARY_PATH=:/usr/local/cuda/lib64

If you are using a 32-bit operating system change lib64 to lib

Second, there should have been some shared object files installed in /usr/lib or /usr/lib64, depending on your operating system. These object files should be contained in a directory called "nvidia". The two files we are concerned with are names libcuda.so.drivernumber and libOpenCL.so.somenumber. To differentiate between the actual shared object files just use ls -l. The symbolic links will show what they are actually linking to.

As root, execute the following commands:

ln -s /usr/lib64/nvidia/libcuda.so.somenumber /usr/lib64/libcuda.so
ln -s /usr/lib64/nvidia/libOpenCL.so.somenumber /usr/lib64/libOpenCL.so

That should allow you to compile all the sources in the SDK.

As of Cuda 5.5 and Ubuntu 12.04/12.10, the command above becomes (notice the Ubuntu and Cuda directory changes) for 64bit

ln -s /usr/local/cuda/lib64/libcuda.so.5.5 /usr/lib/libcuda.so.5.5

That is, the lib folders on Ubuntu as of 12.04 are lib32 and lib; the 64 is implicit, and cuda 5.5 and greater now installs to a different directory.

Upvotes: 13

surendran
surendran

Reputation: 476

create a nvidia_settings.conf file in /etc/ld.so.conf.d/ and add the path to the libs in the file nvidia_settings.conf

 /usr/local/cuda/lib64
 /usr/local/cuda/lib

Now to update the changes run the following command:

sudo ldconfig

Upvotes: 2

rodms
rodms

Reputation: 391

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda/lib

or if you are running cuda-5.0 on a 64-bit machine

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda-5.0/lib64

Upvotes: 1

Edgar
Edgar

Reputation: 801

try:

32-bit: sudo ldconfig /usr/local/cuda/lib

64-bit: sudo ldconfig /usr/local/cuda/lib64

cheers

Upvotes: 80

Jerome Berryhill
Jerome Berryhill

Reputation: 51

LD_LIBRARY_PATH is strongly deprecated. It may mess up other programs, and others may reset it. It should only be used to temporarily override the permanent paths for testing purposes (don't take my word, google it).

Instead, add a line with your cuda lib directory on it to /etc/ld.so.conf, after any existing lines.

For example, if you installed on /usr/local/cuda, you will need to add

32-bit : /usr/local/cuda/lib

64-bit : /usr/local/cuda/lib64

Save, and run ldconfig. This should permanently fix the problem.

The symbolic links are probably already set up by the installation. If not, then add them as Alex advised.

Note - I received errors referencing /lib, but I needed to add lib64 to fix them.

Upvotes: 5

Related Questions