ubuntu16.04 install graphics driver+cuda+cudnn

1. Install the graphics driver

Confirm the required cuda version, take cuda10.1 as an example

1. View version correspondence

In the cuda documentation , check the required cuda corresponding graphics card driver version
Correspondence between cuda version and graphics card driver version
cuda10.1 . The graphics card driver version is required under linux>=418.39

2. Install the graphics driver online

  • Add ppa source
sudo add-apt-repository ppa:graphics-drivers/ppa
sudo apt update
  • View the driver version that supports the current graphics card in the added source
ubuntu-drivers devices

Insert picture description here

  • Install the required graphics driver, take nvidia-430 as an example,
sudo apt install nvidia-430 

Pay attention to the driver name, which should be consistent with the version required in the above picture

  • View graphics card driver information
nvidia-smi

Insert picture description here

Two, install cuda

1. Download

Go to the cuda toolkit archive to download the required cuda version
Insert picture description here

  • Choose the first runfile (local) method (other methods are also available)
  • You can download the installation package by entering the wget command through the terminal
wget https://developer.download.nvidia.com/compute/cuda/10.1/Prod/local_installers/cuda_10.1.243_418.87.00_linux.run
  • You can also copy the link selected in the above picture and download the installation package manually

2. Installation

  • Run the download and hit the .run file to install
sudo sh cuda_10.1.243_418.87.00_linux.run

Insert picture description here
Select continue to continue

Insert picture description here
Enter accept below to continue

Insert picture description here
Remove the X in front of Driver, Don’t install Driver, because it’s installed before and, choose install to start installation

3. Add environment variables

  • Open .banshrc file
sudo gedit ~/.bashrc
  • Add the following three lines at the end of the opened document,The last line is modified to its own version of cuda
export CUDA_HOME=/usr/local/cuda 
export PATH=$PATH:$CUDA_HOME/bin 
export LD_LIBRARY_PATH=/usr/local/cuda-10.2/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
  • Save the file and exit, terminal input
source ~/.bashrc

4. Test whether the installation is successful

  • There are two ways to view the cuda version,Pay attention to spaces and uppercase V
nvcc -V
cat /usr/local/cuda/version.txt

Insert picture description here
Show successful installation of cuda10.1.243

  • You can also use the following method to test
cd /usr/local/cuda/samples/1_Utilities/deviceQuery
sudo make
./deviceQuery

Insert picture description here

Three, install cudnn

1. Install via cuDNN Library for Linux

  • Download the required cudnn on the cudnn official website ,Registration required
    Insert picture description here
    Choose cuDNN Library for Linux (x86)
  • Unzip the downloaded file,Downloaded file name
tar -xzvf cudnn-10.1-linux-x64-v8.0.5.39.tgz
  • Copy files
sudo cp -r cuda/include/ /usr/local/cuda/include/ 
sudo cp -r cuda/lib64/ /usr/local/cuda/lib64/ 
  • Grant permissions
sudo chmod a+r /usr/local/cuda/include/cudnn.h 
sudo chmod a+r /usr/local/cuda/lib64/libcudnn*
  • View cudnn version
cat /usr/local/cuda/include/cudnn.h | grep CUDNN_MAJOR -A 2

or

cat /usr/local/cuda/include/cudnn_version.h | grep CUDNN_MAJOR -A 2

Depending on the version of cudnn, the commands used are different, refer to the link

Insert picture description here

2. Install via deb file

Reference link

Guess you like

Origin blog.csdn.net/kkjsk/article/details/112390338