I have different versions of CUDA installed in /usr/local/cuda-...
and
I need some way to select the right version for different projects.
I tried
export CUDA_HOME=/usr/local/cuda-10.0
export PATH=\$CUDA_HOME/bin${PATH:+:${PATH}}
export LD_LIBRARY_PATH=\$CUDA_HOME/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
but it seems like variables in PATH don't get expanded.
My currently best idea is something like this:
BASEPATH=$PATH:$HOME/installed/pycharm-community-2020.2/bin
LIBBASEPATH=$LD_LIBRARY_PATH
function env100() {
CUDA_HOME=/usr/local/cuda-10.0
setpaths
}
function env101() {
CUDA_HOME=/usr/local/cuda-10.1
setpaths
}
function setpaths() {
export PATH=$BASEPATH:$CUDA_HOME/bin
export LD_LIBRARY_PATH=$LIBBASEPATH:$CUDA_HOME/lib64
}
but I cannot imagine that this is the easiest way to do what I want. And I haven't used it long enough to know all the weird ways in which it will explode, either. (Edit: First thing to explode: Python virtualenvs.)
Related: I am trying to do something similar to this question: What's the right way to set "dynamic" PATH in bash? (for android sdk)
So, let's hear your recommendations!