First, install the driver

1. Download the driver

Go to the NVDIA Driver Search Page and search for the driver model you need for your graphics card and download it (see picture).

Search, then download

2. To disable the nouveau

Open the terminal and enter:

sudo gedit /etc/modprobe.d/blacklist.conf 

Add these two lines to the end of the blacklist.conf file and save:

blacklist nouveau

Then execute the command:

Sudo update-initramfs-u // Apply changes

Restart the computer and verify that Nouveau is disabled. This is used to disable the Nouveau driver. You do not need to change it back later. :

lsmod | grep nouveau

No message return instructions have been disabled as shown in the figure:

3. Install the NVIDIA driver

Open Terminal to uninstall the old NVIDIA driver:

sudo apt-get remove --purge nvidia*

Go to the folder and give the driver run permissions:

Sudo chmod a+x nvidia-linux-x86_64-460.84. run //

Install the NVIDIA driver

Sudo./ nvidia-linux-x86_64-460.84. RUN-NO-X-CHECK-NO-NOUVEAU-CHECK-NO-OPENGL-FILES./ nvidia-linux-x86_64-460.84. RUN-NO-X-CHECK-NO-NOUVEAU-CHECK-NO-OPENGL-FILES
  • -no-x-check: Turn off the X service when the driver is installed
  • -no-nouveau-check: disable nouveau when installing the driver
  • -no-opengl-files: Install only driver files, do not install OpenGL files (most important)

Options during installation:

The distribution-provided pre-install script failed! Are you sure you want to continue? Select Yes to continue. Would you like to register the kernel module souces with DKMS? This will allow DKMS to automatically build a new module, if you install a different kernel later? Select No to continue. Install without signing NVIDIA's 32-bit compatibility libraries? NVIDIA's 32-bit compatibility libraries? Select No to continue. Would you like to run the nvidia-xconfigutility to automatically update your x configuration so that the NVIDIA x driver  will be used when you restart x? Any pre-existing x confile will be backed up. Select Yes

Choosing these options incorrectly can cause the installation to fail, but that’s fine, as long as you don’t make mistakes in the first place, just try it a few times.

Check the NVIDIA version to verify that the installation is complete

Second, install CUDA

1. Download

Go to the official website to download the version of CUDA suitable for your computer, select the corresponding version and install it according to the following methods.

The last Installer Type recommends runfile [local] because it is more convenient with fewer command lines.

In this example, download the file (you can download the link directly from your browser).

2. Install

After downloading, run the following command

Sudo sh cuda_11. 4.0 _470. 42.01 _linux. Run

Enter Accept

Do not download the Driver here, as you have already installed it. Be sure to select Cuda Toolkit 10.2.

The way to deselect is to hover the cursor over
DriverOn that row, and hit enter,
make[]In theXdisappear

Select Install Enter

To verify the success of the installation, enter the following command:

cat /usr/local/cuda/version.txt

If the file is not displayed, go to the folder to see if there is a version. TXT. If there is version.

Next, set the environment variables

gedit ~/.bashrc

Add the following environment variables (change to your own path) :

The export PATH = / usr/local/bin/cuda 11.4 ${PATH: + : ${PATH}} export LD_LIBRARY_PATH = / usr/local/lib64 / cuda 11.4 ${LD_LIBRARY_PATH: + : ${LD_LIBRARY_PATH}}

Save exit, terminal run:

source ~/.bashrc

Terminal operation:

nvcc -V

The installation was successful if the following text is displayed.

Install CUDNN

Go to the website (registration required)

After registering to enter, agree to the agreement, shown below

Select your own version, I need CUDA11, just click on the first one.

There are now two ways to install CUDNN, the first to verify; The second method requires fewer files to download.

The first: a Debian File installation

1. Download

Select the three files in Ubuntu 20 to download locally,

2. Install

Then execute the following three commands

Sudo dpkg-i libcudnn8_8.2.2.26-1+cuda11.4_amd64.deb sudo dpkg-i libcudnn8-dev_8.2.2.26-1+cuda11.4_amd64.deb sudo DPKG -i libcudnn8 - samples_8. 2.2.26-1 + cuda11.4 _amd64. Deb

3. Verify

There are some examples of cudnn in /usr/src/cudnn_samples_v8 when selecting Debian File for installation

Verify by compiling mnistCUDNN sample by expanding the terminal in any directory and running the following command

cp -r /usr/src/cudnn_samples_v8/ $HOME
cd  $HOME/cudnn_samples_v8/mnistCUDNN
make clean && make

Fatal error: freeimage.h; fatal error: freeimage.h; fatal error: freeimage.h

mnistCUDNN  sudo make
Linking agains cublasLt = true
HOST_ARCH: x86_64
TARGET OS: linux
SMS: 35 50 53 60 61 62 70 72 75 80 86
test.c:1:10: fatal error: FreeImage.h: No such file or directory
    1 | #include "FreeImage.h"
      |          ^~~~~~~~~~~~~
compilation terminated.

Sudo apt-get install libfreeimage3 libfreeimage-dev sudo apt-get install libfreeimage-dev

If the installation is successful it will look something like the following: Test passed!

This validation generates a CUDNN_SAMPLES_V8 file in the home directory, which can be deleted if the validation is successful.

The second option: a Tar File installation

1. Download

Select Ubuntu 20 to download this file locally,

2. Install

The download is a compressed TGZ package, which needs to be unzipped first:

The tar - XZVF cudnn - 11.4 - Linux - x64 - v8.2.2.26. TGZ

To perform the installation, you simply copy the header and library files and give permissions

sudo cp cuda/include/cudnn.h /usr/local/cuda/include
sudo cp cuda/lib64/libcudnn* /usr/local/cuda/lib64
sudo chmod a+r /usr/local/cuda/include/cudnn.h 
sudo chmod a+r /usr/local/cuda/lib64/libcudnn*

To complete. The unzip operation will generate a CUDA folder in the current directory, which can be deleted.

Reference (including partial figure) :………