Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

Installing the CUDA toolkit results in the following instructions being printed to the console.

Please make sure your LD_LIBRARY_PATH for 64-bit Linux distributions includes /usr/local/cuda-5.0/lib64:/usr/local/cuda-5.0/lib

OR

for 64-bit Linux distributions add /usr/local/cuda-5.0/lib64 and /usr/local/cuda-5.0/lib to /etc/ld.so.conf and run ldconfig as root

The following code in /etc/profile had no effect.

if [ -z "$LD_LIBRARY_PATH" ]; then    
  LD_LIBRARY_PATH=/usr/local/cuda-5.0/lib64:/usr/local/cuda-5.0/lib
else
  LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda-5.0/lib64:/usr/local/cuda-5.0/lib
fi
export LD_LIBRARY_PATH

That is, rebooting and issuing echo $LD_LIBRARY_PATH showed the variable was not defined.

To try the alternative suggestion, I added the two lines to the file /etc/ld.so.conf so my file looks like this

include /etc/ld.so.conf.d/*.conf 
/usr/local/cuda-5.0/lib64
/usr/local/cuda-5.0/lib

Then I issued:

sudo ldconfig

then

echo $LD_LIBRARY_PATH

Still the environment variable was not set. How do I comply with the CUDA installation instructions shown above?

share|improve this question
    
ldconfig doesn't set LD_LIBRARY_PATH, it includes libraries in a different way. –  handuel Apr 7 '13 at 12:47

2 Answers 2

up vote 3 down vote accepted

Put the following in .bashrc.

if [ -z $LD_LIBRARY_PATH ]; then
  LD_LIBRARY_PATH=/usr/local/cuda-5.0/lib64:/usr/local/cuda-5.0/lib
else
  LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda-5.0/lib64:/usr/local/cuda-5.0/lib
fi
export LD_LIBRARY_PATH
share|improve this answer
    
I think the preferred method is to create a .conf file. I described this in my answer below. –  Logan Mayfield Apr 7 '13 at 12:48

Add a file with the .conf extension to /etc/ld.so.conf.d/ that contains the paths to the libraries and then run ldconfig. Be sure to set the permissions and ownership of the file to match the other files in the directory.

This is a system wide solution as opposed to the user specific solution of modifying .bashrc.

On my system I made nvidia.conf in /etc/ld.so.conf.d/. The file contains the lines:

/usr/local/cuda-5.0/lib64
/usr/local/cuda-5.0/lib

If you create the file as sudo then your permissions should be good to go, but my nvidia.conf is owner/group root and rw-r--r-- (or 644).

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.