Ubuntu20.04 steps to install cuda10.1 (graphic tutorial)

Preparation before installation

The main purpose of CUDA is deep learning, and the current mainstream deep learning framework Tensorflow2 supports up to CUDA 10.1, so this article explains the main process of installing CUDA 10.1 on the Ubuntu 20.04 system.

First, check if your NVIDIA graphics driver supports cuda10.1 version.
Execute the following commands in the terminal:
nvidia-smi

If CUDA Version:… The version number here is greater than or equal to 10.1 (mine is 10.2), you can install cuda10.1.

Key point: gcc downgrade

Because the gcc version that comes with Ubuntu20.04 is 9.3, and cuda10.1 does not support gcc-9, you need to install gcc-7 manually. The command is as follows:

sudo apt-get install gcc-7 g++-7

After installing gcc-7, there are two versions of gcc in the system, so to set the default gcc, the command is as follows:

sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-79
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-91

This command can set the priority of each version of gcc through update-alternatives, the highest priority is the system default version, and the priority can be displayed with the following command:

sudo update-alternatives --display gcc

The same goes for setting the default g++:

sudo update-alternatives --install /usr/bin/g++ g++/usr/bin/g++-79
sudo update-alternatives --install /usr/bin/g++ g++/usr/bin/g++-91

Display g++ priority:

sudo update-alternatives --display g++

Follow the installation steps on the official website to download and install CUDA 10.1

CUDA Toolkit 10.1 update2 Archive

As shown in the figure above, it is recommended to choose the run file to install, which is more concise.

Move to the Install option, press Enter, and wait for the installation to complete.

Configure executable file and library path

After the installation is complete, you need to configure the environment for CUDA 10.1.

First open the .bashrc file in the home directory: gedit ~/.bashrc

Add the following at the end of the file:

export PATH=/usr/local/cuda-10.1/bin${PATH:+:${PATH}}export LD_LIBRARY_PATH=/usr/local/cuda-10.1/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}

Save and close the file to complete the configuration.

Update environment: source ~/.bashrc

Install cuDNN

Download cuDNN

Download cuDNN

After opening the link, the website will ask you to log in. If you do not have an NVIDIA account, log in after registering.

Select the version (7.6.5) corresponding to CUDA 10.1, click to open, select cuDNN Library for Linux, and click to download. (It is better to choose the file format of cuDNN Library for Linux for easier installation)

Install cuDNN

Switch to the directory where the downloaded file is located, and decompress the downloaded cuDNN compressed file to the current directory:

tar zxvf ./cudnn-10.1-linux-x64-v7.6.5.32.tgz -C ./

Will unzip

Copy the cuda/include/cudnn.h file to the /usr/local/cuda/include folder

Copy all files under cuda/lib64/ to the /usr/local/cuda/lib64 folder

Add read and execute permissions for the above files:

sudo chmod 755/usr/local/cuda/include/cudnn.h /usr/local/cuda/lib64/libcudnn*

Installed

Reference article:

Ubuntu 20.04 CUDA&cuDNN installation method
Ubuntu: install cuda10.1 driver

Recommended Posts

Ubuntu20.04 steps to install cuda10.1 (graphic tutorial)
ubuntu19.04 installation tutorial (graphic steps)
Install MySQL under Ubuntu 18.04 (graphic tutorial)
How to install cuda10.1 driver in Ubuntu
Ubuntu18.04 install Nvidia graphics driver tutorial (graphic)
Ubuntu16.04 install Mongodb tutorial
ubuntu14.04 install jdk1.8 tutorial
Windows10 install ubuntu20.04 dual system detailed graphic tutorial
Detailed steps to install Anaconda on Linux (Ubuntu 18.04)
Detailed steps to install Sogou input method on Ubuntu 20.04
5.1. CentOS@ install JDK1.8 graphic tutorial
How to install Helm in Ubuntu
How to install Ruby on Ubuntu 20.04
How to install Memcached on Ubuntu 20.04
How to install Java on Ubuntu 20.04
How to install MySQL on Ubuntu 20.04
How to install VirtualBox on Ubuntu 20.04
How to install Elasticsearch on Ubuntu 20.04
How to install Protobuf 3 on Ubuntu
How to install Apache on Ubuntu 20.04
How to install Git on Ubuntu 20.04
How to install Node.js on Ubuntu 16.04
How to install MySQL on Ubuntu 20.04
How to install Vagrant on Ubuntu 20.04
How to install Bacula-Web on Ubuntu 14.04
How to install Anaconda3 on Ubuntu 18.04
How to install mysql in Ubuntu 14.04
How to install Memcached on Ubuntu 18.04
How to install Jenkins on Ubuntu 16.04
How to install MemSQL on Ubuntu 14.04
How to install Go on Ubuntu 20.04
How to install MongoDB on Ubuntu 16.04
How to install Mailpile on Ubuntu 14.04
How to install PrestaShop on Ubuntu 16.04
How to install Skype on Ubuntu 20.04
How to install Jenkins on Ubuntu 20.04
How to install Python 3.8 on Ubuntu 18.04
How to install KVM on Ubuntu 18.04
How to install KVM on Ubuntu 20.04
How to install opencv3.0.0 on ubuntu14.04
How to install Anaconda on Ubuntu 20.04
How to install Prometheus on Ubuntu 16.04
How to install Jenkins on Ubuntu 18.04
Ubuntu 20.04 CUDA&cuDNN installation method (graphic tutorial)
How to install Apache on Ubuntu 20.04
How to install R on Ubuntu 20.04
How to install Moodle on Ubuntu 16.04
How to install Solr 5.2.1 on Ubuntu 14.04
How to install Teamviewer on Ubuntu 16.04
How to install MariaDB on Ubuntu 20.04
Ubuntu 16.04 installation graphic tutorial under VMware 12
How to install Nginx on Ubuntu 20.04
How to install Mono on Ubuntu 20.04
How to install Go on Ubuntu 20.04
How to install Zoom on Ubuntu 20.04
How to install mysql in Ubuntu 14.04
How to install Nginx on Ubuntu 16.04
How to install OpenCV on Ubuntu 20.04
How to install Spotify on Ubuntu 20.04
How to install Postman on Ubuntu 18.04
How to install Go 1.6 on Ubuntu 16.04