Cannot set LD_LIBRARY_PATH in /etc/profile.d
Note: You can only set this environment variable inside an interactive shell. [ie a terminal ] Since Ubuntu 9.04 Jaunty Jackalope, LD_LIBRARY_PATH cannot be set in $HOME/.profile, /etc/profile, nor /etc/environment files. You must use /etc/ld.so.conf.d/*.conf configuration files. See Launchpad bug #366728 for more information.
How to fix it:
cd /etc/ld.so.conf.d
Make a file with the .conf
extension here
sudo nano cuda.conf
Add the paths to it as two lines
/usr/local/cuda-7.5/lib64
/usr/lib/nvidia-361
Save and exit. Check with ls -l
that the file has the same ownership and permissions as others in the directory, they should be:
-rw-r--r-- 1 root root
Then run
ldconfig
This doesn't set the env variable, but includes the libraries appropriately so CUDA works
Related videos on Youtube
ponir
Updated on September 18, 2022Comments
-
ponir over 1 year
I have installed nVidia CUDA 7.5 in Ubuntu Mate 16.04. However, I am having trouble setting up the environment variables.
Here is the
nvidia-settings.sh
file that I have in/etc/profile.d
folder:export PATH=/usr/local/cuda-7.5/bin:$PATH export LD_LIBRARY_PATH=/usr/local/cuda-7.5/lib64:/usr/lib/nvidia-361:$LD_LIBRARY_PATH export LIBRARY_PATH=/usr/lib/nvidia-361:/usr/local/cuda-7.5/lib64:$LIBRARY_PATH
However, after reboot the
LD_LIBRARY_PATH
environment was not automatically available. Here is the terminal output that shows the issue:ponir@mate:~$ echo $LD_LIBRARY_PATH ponir@mate:~$ echo $LIBRARY_PATH /usr/lib/nvidia-361:/usr/local/cuda-7.5/lib64: ponir@mate:~$ export LD_LIBRARY_PATH=/usr/local/cuda-7.5/lib64:/usr/lib/nvidia-361:$LD_LIBRARY_PATH ponir@mate:~$ echo $LD_LIBRARY_PATH /usr/local/cuda-7.5/lib64:/usr/lib/nvidia-361: ponir@mate:~$
But after executing
export LD_LIBRARY_PATH=/usr/local/cuda-7.5/lib64:/usr/lib/nvidia-361:$LD_LIBRARY_PATH
in Terminal I could get that variable.What could be the issue? Thanks.
-
edwinksl almost 8 yearsYou should have done
echo $LD_LIBRARY_PATH
andecho $LIBRARY_PATH
to see if these two environment variables exist. -
ponir almost 8 years
echo $LD_LIBRARY_PATH
gives a blank output as well. -
edwinksl almost 8 yearsCan you update your question with the output from using
echo
? That removes the "No such file or directory" noise that is distracting us from the core of your question. -
ponir almost 8 yearsI have recreated the issue in a new terminal and this time using echo. I have updated the question. I think there is something wrong in my
nvidia-settings.sh
file. But cannot figure out what!
-
-
ponir almost 8 yearsI do remember setting up
LD_LIBRARY_PATH
in Ubuntu 14.04. And it worked there. The problem withldconfig
is that it gives an error withlibcudnn.so.4
files (cuDNN v4):/sbin/ldconfig.real: /usr/local/cuda-7.5/lib64/libcudnn.so.4 is not a symbolic link
as these are non standard library. And packages needLD_LIBRARY_PATH
variable in order to load cuDNN. -
Zanna almost 8 yearsYou should be able to fix that error from
ldconfig
: see here @ponir