Coexistence of CUDA8.0 and CUDA9.0 under Ubuntu 16.04

Foreword

On Github, the environment required for some earlier code may be CUDA8.0. For a novice, normal thinking will choose the most cash version for environment configuration. Here is a brief introduction how to use [GPU] (https://cloud.tencent.com/product/gpu?from=10680) When performing calculations, CUDA8.0 and CUDA9.0 coexist.

1、 Check before installation

Run the following command to check the current CUDA version of your computer

nvcc --version 

My own computer displays as follows: (CUDA9.0 currently installed in my computer)

2、 Download the appropriate CUDA8.0 version

When choosing CUDA8.0 version, you must choose according to your own computer system and corresponding environment, download link
In the corresponding download link interface, proceed as follows: (My own Ubuntu server, 16.04, here we choose the runfile installation form)

Tips: Since mine is on the server side, if someone is also installing on the server side, remember to upload the downloaded file to the server side first.

3、 Perform the appropriate installation

In the corresponding folder you downloaded, perform the following operations:

cd CUDA8     #Go to the folder containing the above downloaded file
sudo chmod 777 cuda_8.0.61_375.26_linux.run   ##Give files certain permissions
. /cuda_8.0.61_375.26_linux.run    ##start installation

After running the installation instructions, Nvidia's introduction document will appear, such as the following:

The most important point is that the introduction document requires some operations from you, otherwise the installation process cannot continue, there are two ways to skip the introduction document

After you skip the introduction document, there will be some options that you need to choose: (The input corresponding to each step is marked with a red circle in the figure below. Here is an explanation: Driver must select n, because You have installed a driver that supports CUDA9.0 before, so you don’t need to install a new one)

4、 Make the corresponding environment configuration

Enter the following installation path, open the bashrc file, and then locate to the lowest end (see the figure below for the operation process)

As you can see, on my computer side, the imported paths are all cuda9.0:

Here, if we want to use the CUDA8.0 just installed, we only need to do the following:
Replace the corresponding cuda-9.0 with cuda-8.0, as shown in the figure below (exit after saving)

Then in the terminal, execute the following command to source:

source ~/.bashrc

Then you can perform the corresponding verification: (As shown in the figure below, you can see that the CUDA8.0 version is installed successfully)

5. Switch between multiple cuda versions

The above is only the case when you want to use one of them. If you often want to switch between versions, the following method is recommended:
Change all cuda-related paths under ~/.bashrc to /usr/local/cuda/ instead of /usr/local/cuda-8.0/ or /usr/local/cuda-9.0/.

 # When switching cuda version
 rm -rf /usr/local/cuda#Delete the soft link created before
 sudo ln -s /usr/local/cuda-8.0/usr/local/cuda
 nvcc --version #View the current cuda version
  
 nvcc:NVIDIA(R) Cuda compiler driver
 Copyright(c)2005-2016 NVIDIA Corporation
 Built on Mon_Jan_23_12:24:11_CST_2017
 Cuda compilation tools, release 8.0, V8.0.62
  
 # cuda8.0 Switch to cuda9.0 
 rm -rf /usr/local/cuda
 sudo ln -s /usr/local/cuda-9.0/usr/local/cuda
 nvcc --version

The modification method of ~/.bahsrc file is the same as above.

6、 to sum up

The above just talked about how to convert from CUDA9.0 to CUDA8.0. If you want to switch back to CUDA9.0, you only need to perform the opposite process, change the cuda-8.0 in the bashrc file to cuda-9.0, and then source it. , You can.

Recommended Posts

Coexistence of CUDA8.0 and CUDA9.0 under Ubuntu 16.04
Installation and uninstallation of CUDA under Ubuntu 16.04
[python] python2 and python3 under ubuntu
Installation of pulseaudio and API usage under Ubuntu 12.04
Use of mediawiki under ubuntu
Installation and use of GDAL in Python under Ubuntu
Installation and usage instructions of rz/sz command under ubuntu
Installation of deb package under Ubuntu
Install and deploy Gerrit under Ubuntu
Redis installation under ubuntu and windows
Install nodejs and npm under Ubuntu 16.04
Installation of Docker CE under Ubuntu
Compile and install QEMU under Ubuntu
Install the latest version of Thunderbird and exchange plugins under ubuntu
ubuntu Docker installation and deployment of Rancher
Installation and use of Mysql under CentOS
51 MCU program development and download under Ubuntu
Installation and configuration of redis under centos7
Installation and deployment of Nginx in Ubuntu
Installation and use of Win10 subsystem Ubuntu
Install and uninstall CUDA and CUDNN on Ubuntu
GPU programming (1): CUDA8.0 environment construction under Ubuntu
DLNA/UPnP Server installation and configuration under Ubuntu 12.04
Configure node js and npm under Ubuntu 14.04
Ubuntu 16.04 Cuda8.0 tensorflow-gpu
Expand the disk size of Ubuntu under VMware
Summary of methods to use Evernote under Ubuntu 14.04
Summary of Ubuntu system and privacy cleaning tools
The basic configuration and interface beautification of Ubuntu
Install the old version of seurat under Ubuntu
Installation and configuration of rsync server under CentOS 6.5
Kaldi installation and configuration graphic tutorials under Ubuntu
Installation, configuration and uninstallation of GitLab in Ubuntu19.1
Audio and video editing tool stack under ubuntu
Installation and use of SSH in Ubuntu environment
Install apache+PHP under Ubuntu
Install node.js under Ubuntu
How to repackage Deb files under Debian and Ubuntu
Ubuntu16.04 mirror complete installation and configuration tutorial under VMware
Summary: Ubuntu Python2.x and
Install python3.6 under Ubuntu 16.04
Implementation steps of opening and viewing Ubuntu cron logs
Install win7 and archlinux on hard disk under ubuntu
Install mysql under Ubuntu 16.04
Install Thrift under ubuntu 14.10
Install OpenJDK10 under Ubuntu
Install Caffe under Ubuntu 14.04
Python MySQLd under Ubuntu
Start working under ubuntu
Installation and cracking of Jira7 operation records under Centos
Add new users under ubuntu and kick out online users
Ubuntu20.04 experience and beautification
Detailed explanation of static DNS configuration under Ubuntu system
Ubuntu introduction and installation
Use iptables under ubuntu
Compile and install OpenJDK8 from source code under Ubuntu 18.04.1
Installation and simple practice of MySQL in ubuntu environment (1)
Install ROS under ROS Ubuntu 18.04[2]
Cpp web (1) Install and use Crow service under Ubuntu
How to install two versions of OpenCV under ubuntu?
Install MySQL under Ubuntu