Multiple CUDA versions can be installed in /usr/local
the path at the same time, using soft links to switch versions
1. View the installed CUDA version
All installed CUDA versions are saved in /usr/local
the path by default, cd to this path and use ls
the command to view:
the folder cuda-11.0
indicates that CUDA11.0 version is installed on the current computer.
2. View the currently used CUDA version
View the currently used CUDA version /usr/local
through the command in the path: the above figure shows that the current soft link is established on the directory, indicating that the current version is CUDA11.0.stat cuda
cuda-11.0
Use cat cuda/version.txt
to reconfirm:
3. Install the new CUDA version - CUDA10.0
1. Download the corresponding version of the CUDA installation package (select to download the runfile file)
2. In the directory of the downloaded file, sudo sh cuda_10.0.130_410.48_linux.run
install it through the command. The options during the installation process are as follows:
#..一堆协议说明...
#直接按q退出协议说明.
accept/decline/quit: accept #接受协议
Install NVIDIA Accelerated Graphics Driver for Linux-x86_64 410.48?
y)es/(n)o/(q)uit: n #是否显卡驱动包,由于已经安装显卡驱动,选择n
Install the CUDA 10.0 Toolkit?
(y)es/(n)o/(q)uit: y #是否安装工具包,选择y
Enter Toolkit Location
[ default is /usr/local/cuda-10.0 ]: #工具包安装地址,默认回车即可
Do you want to install a symbolic link at /usr/local/cuda?
(y)es/(n)o/(q)uit: n #添加链接**注意这个连接,如果之前安装过另一个版本的cuda,除非你确定想要用这个新版本的cuda,否则这里就建议选no,因为指定该链接后会将cuda指向这个新的版本**
Install the CUDA 10.0 Samples?
(y)es/(n)o/(q)uit: n #不安装样例
After installation, in /usr/local
the path, use ls
the command to check whether there is a newly installed CUDA directory:
it can be seen that the newly installed CUDA10.0 already exists in this directory.
Fourth, install the corresponding cuDNN (version 7.4)
After installing the new version of CUDA, the corresponding cuDNN must also be installed.
1. First download the corresponding version of cuDNN
2. cd to the folder where cudnn is located to decompress and other operations:
tar -zxvf cudnn-10.0-linux-x64-v7.4.2.24.tgz
sudo cp cuda/include/cudnn.h /usr/local/cuda-10.0/include/
sudo cp cuda/lib64/libcudnn* /usr/local/cuda-10.0/lib64/
sudo chmod a+r /usr/local/cuda-10.0/include/cudnn.h /usr/local/cuda-10.0/lib64/libcudnn*
cd /usr/local/cuda-10.0/lib64/
sudo ln -sf libcudnn.so.7.4.2 libcudnn.so.7
Five, CUDA version switching
1. Delete the original version of cuda soft link
sudo rm -rf /usr/local/cuda
2. Establish a new soft connection pointing to cuda-10.0
sudo ln -s /usr/local/cuda-10.0 /usr/local/cuda
3. Check the current CUDA version again
Show that the currently used CUDA version has been converted to CUDA10.0
Replenish
Confirm whether cuda has been added to the environment variable, and use the following command to open the configuration file on the command line:
sudo gedit ~/.bashrc
At the end, confirm whether there are the following lines
export PATH=/usr/local/cuda/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH
export CUDA_HOME=/usr/local/cuda
If not, add it to ~/.bashrc
the end of the , then run the command
source ~/.bashrc
Make the configured environment variables take effect.