Cannot set LD_LIBRARY_PATH in /etc/profile.d

5,186

From Ubuntu wiki help page

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

Share:
5,186

Related videos on Youtube

ponir
Author by

ponir

Updated on September 18, 2022

Comments

  • ponir
    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
      edwinksl almost 8 years
      You should have done echo $LD_LIBRARY_PATH and echo $LIBRARY_PATH to see if these two environment variables exist.
    • ponir
      ponir almost 8 years
      echo $LD_LIBRARY_PATH gives a blank output as well.
    • edwinksl
      edwinksl almost 8 years
      Can 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
      ponir almost 8 years
      I 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
    ponir almost 8 years
    I do remember setting up LD_LIBRARY_PATH in Ubuntu 14.04. And it worked there. The problem with ldconfig is that it gives an error with libcudnn.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 need LD_LIBRARY_PATH variable in order to load cuDNN.
  • Zanna
    Zanna almost 8 years
    You should be able to fix that error from ldconfig : see here @ponir