phohenecker / switch-cuda Goto Github PK
View Code? Open in Web Editor NEWA simple bash script for switching between installed versions of CUDA.
License: MIT License
A simple bash script for switching between installed versions of CUDA.
License: MIT License
When I use the script source-cuda.sh to change the cuda version, the LD_LIBRARY_PATH and other variables are properly set but I am unable to even run nvidia-smi. As a matter of fact, even basic commands are not working. I am wondering what could be the problem. Any help would be appreciated.
Also, will creating a symbolic link to /usr/local/cuda achieve the expected behavior? In my case, I tried creating a symbolic link to cuda 10.0 but nvidia-smi is still showing that the Cuda version is 10.2.
Hello, I am glad to use this convenient script. I would like to use it by using a function, which I think maybe easy to use. Maybe I can pull a request.
# FROM https://github.com/phohenecker/switch-cuda/blob/master/switch-cuda.sh
cudas() {
set -e
INSTALL_FOLDER="/usr/local"
TARGET_VERSION=${1}
if [[ -z ${TARGET_VERSION} ]]; then
echo "The following CUDA installations have been found (in '${INSTALL_FOLDER}'):"
ls -l "${INSTALL_FOLDER}" | egrep -o "cuda-[0-9]+\\.[0-9]+$" | while read -r line; do
echo "* ${line}"
done
set +e
return
elif [[ ! -d "${INSTALL_FOLDER}/cuda-${TARGET_VERSION}" ]]; then
echo "No installation of CUDA ${TARGET_VERSION} has been found!"
set +e
return
fi
cuda_path="${INSTALL_FOLDER}/cuda-${TARGET_VERSION}"
path_elements=(${PATH//:/ })
new_path="${cuda_path}/bin"
for p in "${path_elements[@]}"; do
if [[ ! ${p} =~ ^${INSTALL_FOLDER}/cuda ]]; then
new_path="${new_path}:${p}"
fi
done
ld_path_elements=(${LD_LIBRARY_PATH//:/ })
new_ld_path="${cuda_path}/lib64:${cuda_path}/extras/CUPTI/lib64"
for p in "${ld_path_elements[@]}"; do
if [[ ! ${p} =~ ^${INSTALL_FOLDER}/cuda ]]; then
new_ld_path="${new_ld_path}:${p}"
fi
done
export CUDA_HOME="${cuda_path}"
export CUDA_ROOT="${cuda_path}"
export LD_LIBRARY_PATH="${new_ld_path}"
export PATH="${new_path}"
echo "Switched to CUDA ${TARGET_VERSION}."
set +e
}
_cudas_autocomplete() {
local cur prev opts
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
# Directly place the logic for getting CUDA versions here
INSTALL_FOLDER="/usr/local"
opts=$(ls -l "${INSTALL_FOLDER}" | egrep -o "cuda-[0-9]+\\.[0-9]+$" | awk -F- '{print $2}')
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
return 0
}
complete -F _cudas_autocomplete cudas
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.