How to change CUDA version
Solution 1
Change your CUDA soft link to point on your desired CUDA version. For example:
ll /usr/local/cuda lrwxrwxrwx 1 root root 19 Sep 06 2017 /usr/local/cuda -> /usr/local/cuda-8.0/
Simply relink it with
Update: If the symlink already exists, use this other command:
[[email protected] ~]$ ls /usr/local/cuda
lrwxrwxrwx. 1 root root 20 Sep 14 08:03 /usr/local/cuda -> /usr/local/cuda-10.2
[[email protected] ~]$ sudo ln -sfT /usr/local/cuda/cuda-11.1/ /usr/local/cuda
[[email protected] ~]$ ls /usr/local/cuda
lrwxrwxrwx. 1 root root 26 Sep 14 13:25 /usr/local/cuda -> /usr/local/cuda/cuda-11.1/
ln -s /usr/local/cuda-7.5 /usr/local/cuda
(With the proper installation location)
Solution 2
Maybe a bit late, but I thought it might still be helpful for anyone who comes across this question. I wrote a simple bash script for switching to a different version of CUDA within the current bash session: https://github.com/phohenecker/switch-cuda
Solution 3
I solved the problem finally.
Modifying ~/.bash_profile to change the path to CUDA is the correct way. But when you changed the file, you need to relaunch the bash.
Simply source ~/.bash_profile won't work. Because source will only append the content in the file to the already existed path rather than cover it.
Solution 4
Perhaps cleaner:
sudo update-alternatives --display cuda
sudo update-alternatives --config cuda
Related videos on Youtube
baNv
Updated on November 21, 2021Comments
-
baNv about 1 yearI met this error when compiling a modified caffe version.
OpenCV static library was compiled with CUDA 7.5 support. Please, use the same version or rebuild OpenCV with CUDA 8.0I have some old code may not compatible with CUDA8.0, so I want to change my cuda version for this error.
I modified my ~/.bash_profile like this
# export PYTHONPATH=$PYTHONPATH:/usr/local/cuda-8.0/lib64/ # export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda-8.0/lib64 export PYTHONPATH=$PYTHONPATH:/usr/local/cuda-7.5/targets/x86_64-linux/lib/ export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda-7.5/targets/x86_64-linux/lib/But it did't work. Still the same error. What should I do? Thanks.
-
Olivia Stork over 4 yearsIf you use theln -scommand, it will fail if the symlink already exists. So remove the old symlink with a simplesudo rm /usr/local/cuda. (As always, be very careful with your paths when usingsudo rm!) -
Shuai.Z over 3 yearsI don't have the sudo permission, and got the following error ln: failed to create symbolic link ‘/usr/local/cuda-10.0/cuda-8.0’: Permission denied -
Olivia Stork over 3 yearsYou can also usesudo ln -sfto create OR update the symlink if it already exists. Then you won't need thermcommand. -
chris over 2 yearsThis doesn't work for me - after a reboot, the symlink is correct, butnvidia-smigives me the wrong version. -
yuqli over 2 years@ChrisAndersonnvidia-smiis showing the cuda version for driver API. Usenvcc --versionto find out cuda version. See here stackoverflow.com/questions/53422407/… -
Louis Maddox over 1 yearOddlysudo ln -sfdoesn't work for me (on an Ubuntu 20.04 based distro, ln version 8.30), I agree it should do... Had no effect. Cannot reproduce in my own namespace without sudo... -
Fang WU over 1 yearGreat thank! Your toolkit is really useful. For the most of time, I have no access to the sudo authority. -
Mona Jalal over 1 year@LouisMaddox check the edits I made to the post -
im0j about 1 yearThis is the best answer. Simple commands, no need to install anything else, & reversible.