Skip to content

Instantly share code, notes, and snippets.

@KorewaLidesu
Created March 4, 2026 17:25
Show Gist options
  • Select an option

  • Save KorewaLidesu/b5836b7984a87a5e8ff12d135ec73915 to your computer and use it in GitHub Desktop.

Select an option

Save KorewaLidesu/b5836b7984a87a5e8ff12d135ec73915 to your computer and use it in GitHub Desktop.
Switching CUDA version inside fish
function cuda_switch -a cuda_version
if test -z $cuda_version
echo "cuda_switch info : Switch to default CUDA"
echo "To switch to specific version, append after the command (eg: cuda_switch 11.7)"
set PATH (echo "$PATH" | sed "s/\/opt\/cuda[-0-9\.]*/\/opt\/cuda/")
set CUDA_PATH "/opt/cuda"
else if test -e /opt/cuda-$cuda_version
echo "cuda_switch info : Found CUDA $cuda_version at /opt/cuda-$cuda_version"
echo "Switching to CUDA $cuda_version"
set PATH (echo "$PATH" | sed "s/\/opt\/cuda[-0-9\.]*/\/opt\/cuda-$cuda_version/")
set CUDA_PATH "/opt/cuda-$cuda_version"
else
echo "cuda_switch error : Specified CUDA version not found"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment