CUDA8.0 and CUDA9.0 coexist under Ubuntu16.04

CUDA8.0 and CUDA9.0 coexist under Ubuntu16.04

Preface

Some of the earlier codes on Github may require the CUDA 8.0 environment. For a novice, the normal thinking is to choose the latest version for environment configuration. Here is a brief introduction on how to solve the coexistence of CUDA 8.0 and CUDA 9.0 when using GPU for computing.

1. Inspection before installation

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

nvcc --version

My own computer shows the following: (CUDA 9.0 is currently installed on my computer)

2. Download the appropriate CUDA 8.0 version

When choosing the CUDA 8.0 version, you must choose it according to your computer system and the corresponding environment. The download link is in the corresponding download link interface, and follow the following instructions: (My own is Ubuntu server, 16.04, here we choose the runfile installation method)



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

3. Perform the corresponding installation

In the downloaded folder, do the following:

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

After running the installation instructions, an introduction document from Nvidia will appear, such as the one shown below:


The most important point is that the introduction document requires some actions on your part, otherwise the installation process cannot continue. There are two ways to skip the introduction document:

  • Keep pressing Enter until you see some options that require you to enter Y or N
  • Press Esc to exit the introduction document

After you skip the introduction document, you will be presented with some options for you to choose from: (The inputs for each step are marked with red circles in the figure below. Here is an explanation: Driver must be set to n, because you have already installed a driver that supports CUDA 9.0, so you do not need to install a new one)

4. Perform corresponding environment configuration

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


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


Here, if we want to use the CUDA 8.0 that we just installed, we only need to do the following:
Replace the corresponding cuda-9.0 with cuda-8.0, as shown in the following figure (save and exit)


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

source ~/.bashrc 


Next, you can perform the corresponding verification: (As shown in the figure below, you can see that CUDA 8.0 version has been installed successfully)

5. Switch between multiple cuda versions

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

 #When switching cuda versions rm -rf /usr/local/cuda#Delete the soft link created previously 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 for the ~/.bahsrc file is the same as above.

6. Summary

The above only talks about how to convert from CUDA9.0 to CUDA8.0. If you want to switch back to CUDA9.0, just do the opposite process, replace cuda-8.0 in the bashrc file with cuda-9.0, and then source it.

This is the end of this article about the coexistence of CUDA8.0 and CUDA9.0 under Ubuntu16.04. For more information about the coexistence of CUDA8.0 and CUDA9.0, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope everyone will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • Ubuntu installs multiple versions of CUDA and switches at any time
  • Implementation of installing and uninstalling CUDA and CUDNN in Ubuntu
  • Detailed tutorial on installing CUDA9.0 on Ubuntu16.04
  • Steps to install cuda10.1 on Ubuntu 20.04 (graphic tutorial)
  • Ubuntu installation cuda10.1 driver implementation steps
  • Ubuntu 20.04 CUDA & cuDNN Installation Method (Graphical Tutorial)
  • Detailed tutorial on installing nvidia driver + CUDA + cuDNN in Ubuntu 16.04
  • How to install multiple versions of CUDA in ubuntu16.04

<<:  Detailed explanation of the usage of scoped slots in Vue.js slots

>>:  Summary of MySQL 8.0 memory-related parameters

Recommend

In-depth discussion on auto-increment primary keys in MySQL

Table of contents Features Preservation strategy ...

Detailed explanation of nginx forward proxy and reverse proxy

Table of contents Forward Proxy nginx reverse pro...

How to use vue filter

Table of contents Overview Defining filters Use o...

JavaScript Canvas implements Tic-Tac-Toe game

This article shares the specific code of JavaScri...

Index Skip Scan in MySQL 8.0

Preface MySQL 8.0.13 began to support index skip ...

Detailed steps to install nginx on Apple M1 chip and deploy vue project

brew install nginx Apple Mac uses brew to install...

Analyze the difference between computed and watch in Vue

Table of contents 1. Introduction to computed 1.1...

React handwriting tab switching problem

Parent File import React, { useState } from '...

MySQL Series Database Design Three Paradigm Tutorial Examples

Table of contents 1. Knowledge description of the...