How to install CUDA and nvidia-driver

How to install CUDA and nvidia-driver

-** CUDA ** (Compute Unified Device Architecture) is a development environment for creating GPU-accelerated applications developed by Nvidia.

-** nvidia-driver **, as the name suggests, is a driver for controlling Nvidia GPUs such as the GTX and RTX series.

To briefly explain these two roles, ** nvidia-driver ** acts as an intermediary between hardware and OS, and a toolkit (application group) called ** CUDA ** is used for programs such as python. Provides resources.

Installation method

In the past, it was necessary to stop the running graphic driver, re-burn the kernel with dkms, etc., but today it can be easily installed with just one deb file.

Here are the steps to install CUDA 11.2 on Ubuntu 16.04.

1. Select your environment from the CUDA toolkit distribution site and check the .deb file download command.

First, access CUDA Toolkit 11.2 Downloads.

--If you select Linux-> x86_64-> Ubuntu-> 16.04-> deb (local)

Download Installer for Linux Ubuntu 16.04 x86_64

You will see how to download the .deb file in the content box.

edit.png

2. Install CUDA using the deb file

The commands actually displayed are shown below, but since they are just examples, be sure to enter the commands displayed in the content box when you operated them yourself.

#Register priority in repository
wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64/cuda-ubuntu1604.pin
sudo mv cuda-ubuntu1604.pin /etc/apt/preferences.d/cuda-repository-pin-600

#Download deb file
wget https://developer.download.nvidia.com/compute/cuda/11.2.0/local_installers/cuda-repo-ubuntu1604-11-2-local_11.2.0-460.27.04-1_amd64.deb

#Install packages on your system using deb files
sudo dpkg -i cuda-repo-ubuntu1604-11-2-local_11.2.0-460.27.04-1_amd64.deb
sudo apt-key add /var/cuda-repo-ubuntu1604-11-2-local/7fa2af80.pub

#Updated package list
sudo apt-get update

3. Install the meta package that suits your environment

I was able to install the package with dpkg -i, but it has not been reflected in the system yet. Finally, use the sudo apt install command to apply the package to your system, but be careful here. In the content box, it says sudo apt install cuda, but you need to change the metapackage to reflect it according to your purpose.

The list of meta packages is excerpted from the official website (3.10.3. Meta Packages) and translated into Japanese below.   The following two meta packages are mainly specified.

By the way, in the case of CUDA 10.1, the meta package name is cuda-10-1. Please convert it on a case-by-case basis.

Meta Package Purpose
cuda Install all CUDA toolkits and driver packages. When a new cuda package is released, it will automatically handle the upgrade to the next version.
cuda-11-2 Install all CUDA toolkits and driver packages. Versions until an additional version of CUDA is installed11.2It will be fixed as it is.
cuda-toolkit-11-2 Install all the CUDA toolkit packages needed to develop CUDA applications. Driver not included.
cuda-tools-11-2 Install all CUDA command line and visual tools.
cuda-runtime-11-2 Install all the CUDA toolkit packages and driver packages needed to run your CUDA application.
cuda-compiler-11-2 Install all CUDA compiler packages.
cuda-libraries-11-2 Install all runtime CUDA library packages.
cuda-libraries-dev-11-2 Install all development CUDA library packages.
cuda-drivers Install all driver packages. Upon release, it handles upgrades to the next version of the driver package.
sudo apt install cuda-11-2

Or

sudo apt install cuda-toolkit-11-2

Apply the CUDA package to your system with.

I want to manage multiple CUDA.

** CUDA ** and ** nvidia-driver ** are compatible. If you want to know more, please refer to the official website below.

Nvidia: Binary Compatibility

CUDA Toolkit Linux x86_64 Driver Version
CUDA 11.1 (11.1.0) >= 450.80.02
CUDA 11.0 (11.0.3) >= 450.36.06
CUDA 10.2 (10.2.89) >= 440.33
CUDA 10.1 (10.1.105) >= 418.39
CUDA 10.0 (10.0.130) >= 410.48
CUDA 9.2 (9.2.88) >= 396.26
CUDA 9.1 (9.1.85) >= 390.46
CUDA 9.0 (9.0.76) >= 384.81
CUDA 8.0 (8.0.61 GA2) >= 375.26
CUDA 8.0 (8.0.44) >= 367.48
CUDA 7.5 (7.5.16) >= 352.31
CUDA 7.0 (7.0.28) >= 346.46

--If nvidia-driver == 410.48 is installed --CUDA 10.0, 9.2, 9.1 ... etc. can be installed, but CUDA11.0 cannot be installed. Please check in advance if the CUDA you are installing now is compatible with the driver.

By the way, I think about these things when I am in the following situation.

--When you can't or don't want to change the version of nvidia-driver --When working with Google colab --When installing CUDA additionally on a machine that has already built the environment

If you operate nvidia-driver poorly, you will end up destroying the environment and reinstalling the OS. Tedious.

CUDA installation location and how to switch

The reality of CUDA is in / usr/local. These are / usr/local/cuda11-2 and/usr/local/cuda10-2. However, programs such as python do not refer to them directly. Refer to a symbolic link called cuda.

Console


hoge@hoge:/usr/local$ ls -la
drwxr-xr-x 12 root root 4096 October 15 10:10 .
drwxr-xr-x 13 root root 4096 October 15 10:10 ..
~~~
lrwxrwxrwx 1 root root 9 October 15 10:10 cuda -> cuda-11.2
drwxr-xr-x 16 root root 4096 December 31 23:59 cuda-11-2
drwxr-xr-x 16 root root 4096 October 15 10:10 cuda-10-2
~~~

In the above situation, you can see that referencing the cuda directory is equivalent to referencing the cuda-11-2. If you want to change to cuda10-2, re-paste the link to cuda with the ln -nfs cuda-10-2 cuda command. By doing this, you can manage and operate multiple versions of CUDA.

installation location of cudnn

As an aside, a library called cudnn is located in /usr/include/cudnn.h. If you want to check these versions, you can check the versions by typing:

cat /usr/include/cudnn.h | grep CUDNN_MAJOR -A 2

cudnn depends on the version of CUDA. So if you change the version of CUDA, you need to uninstall the cudnn and then install the appropriate version.

Recommended Posts

How to install CUDA and nvidia-driver
How to install and configure blackbird
How to install and use Graphviz
How to install and use pandas_datareader [Python]
How to install DLIB with 2020 / CUDA enabled
How to install fabric and basic usage
How to install Python
How to install python
How to install Nbextensions
How to install Prover9
How to install Cascade detector and how to use it
[2020.8 latest] How to install Python
How to install Python [Windows]
Tabpy 1.0 (2020-01 version) How to install
How to install mkl numpy
How to install Pelican blog
How to install Git GUI and Gitk on CentOS
How to install mysql-connector-python on mac
How to install python-pip with ubuntu20.04LTS
How to install graph-tool on macOS
How to install wkhtmltopdf (Amazon Linux2)
How to install VMware-Tools on Linux
How to install pycrypto on Windows
How to install OpenCV on Mac
How to install MBDyn (Linux Ubuntu)
How to install PyPy on CentOS
How to install TensorFlow on CentOS 7
How to use .bash_profile and .bashrc
How to install mysql-connector with pip3
How to install Maven on CentOS
How to install Go on Ubuntu
How to install music 21 on windows
How to install Anaconda with pyenv
How to solve slide puzzles and 15 puzzles
How to install OpenCV on Cloud9 and run it in Python
How to install pandas on EC2 (How to deal with MemoryError and PermissionError)
[EC2] How to install and download chromedriver from the command line
[Linux] How to subdivide files and folders
How to split and save a DataFrame
How to install aws-session-manager-plugin on Manajro Linux
How to install drobertadams / toggl-cli on Mac
How to update to Chainer 2.0 (Windows + CUDA 8.0 + CUDNN)
python3 How to install an external module
How to install CatBoost [as of January 2020]
How to install a package using a repository
How to install Anisble on Amazon Linux 2
How to install richzhang / colorization on Windows 10
How to install your own (root) CA
python: How to use locals () and globals ()
How to install Windows Subsystem For Linux
How to install Apache (httpd) on CentOS7
How to install php7.4 on Linux (Ubuntu)
How to install Eclipse GlassFish 5.1.0 on CentOS 7
[Python] How to calculate MAE and RMSE
How to use Python zip and enumerate
How to install Apache (httpd) on CentOS8
How to install zsh (with .zshrc customization)
How to install NumPy on Raspberry Pi
How to use is and == in Python
How to use pandas Timestamp and date_range
How to install cx_Oracle on macOS Sierra