In order to setup CUDA 9.1, I read it is convenient to add its installation folder to PATH
and LD_LIBRARY_PATH
, as:
PATH="/usr/local/cuda-9.1/bin:$PATH"
LD_LIBRARY_PATH="/usr/local/cuda-9.1/lib64:$LD_LIBRARY_PATH"
Following this and this SE answers I tried to edit my .profile
file adding the last lines as below.
# ~/.profile: executed by the command interpreter for login shells.
# This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login
# exists.
# see /usr/share/doc/bash/examples/startup-files for examples.
# the files are located in the bash-doc package.
# the default umask is set in /etc/profile; for setting the umask
# for ssh logins, install and configure the libpam-umask package.
#umask 022
# if running bash
if [ -n "$BASH_VERSION" ]; then
# include .bashrc if it exists
if [ -f "$HOME/.bashrc" ]; then
. "$HOME/.bashrc"
fi
fi
# set PATH so it includes user's private bin directories
PATH="$HOME/bin:$HOME/.local/bin:$PATH"
# settings for CUDA
PATH="/usr/local/cuda-9.1/bin:$PATH"
LD_LIBRARY_PATH="/usr/local/cuda-9.1/lib64:$LD_LIBRARY_PATH"
With .profile
as above, I can open a terminal and run echo $PATH
to see the instruction worked, as PATH
now contains the folder I indicated. However, for some reason this doesn't work for LD_LIBRARY_PATH
.
I guessed the problem might have been that LD_LIBRARY_PATH
did not exist before, so I attempted to modify .profile
with the slightly different code below at the last 2 lines.
PATH="/usr/local/cuda-9.1/bin:$PATH"
export LD_LIBRARY_PATH=/usr/local/cuda-9.1/lib64
Again, however, unsuccessfully.
Noticing the first warning at the beginning of .profile
, I checked whether I had a ~/.bash_profile
or a ~/.bash_login
files. They do not exist, and in any case they would not explain how my PATH
gets successfully updated.
Doing some research, I stumbled upon this other answer, which explains that .profile
is not necessarily executed when I open a terminal. However, again, how can I explain that PATH
is updated?
What could be the problem? Is there something wrong with my syntax?
EDIT:
I tried to log off and on after I changed the .profile
to contain
PATH="/usr/local/cuda-9.1/bin:$PATH"
export LD_LIBRARY_PATH=/usr/local/cuda-9.1/lib64
and it now works. If I enter a terminal and type echo $LD_LIBRARY_PATH
I finally see it. I still do not understand why the first version of my instruction list did not work...
VAR=x
it actually does work. My assumption has been that anything working on terminal would have worked in.profile
. Do you know the reason there's a mismatch? Perhaps because terminal variables are 'temporary'? – raggot Feb 21 '18 at 08:38