Cannot set LD_LIBRARY_PATH in /etc/profile.d

Solution 1:

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