Ubuntu installation graphics driver and cuda tutorial

Ubuntu installation graphics driver and cuda tutorial

Written at the beginning:

The latest version is not necessarily the best, the appropriate one is the best, cuda10.1+cudnn7.6.5 is recommended

1. Uninstall the original driver

#View the installed packages apt list --installed|grep -i nvidia
#Uninstall package apt-get purge nvidia*

2. Download the new graphics card driver

https://www.nvidia.cn/Download/index.aspx?lang=cn

insert image description here

Copy the download link and download it using wget in your system

#Download wget https://cn.download.nvidia.cn/tesla/470.57.02/NVIDIA-Linux-x86_64-470.57.02.run
#install sudo sh NVIDIA-Linux-x86_64-470.57.02.run

2.1 Install the graphics card driver

insert image description here

insert image description here

insert image description here

3 Install CUDA

Official website link

Select the cuda version, which should be consistent with the driver's cuda version

wget https://developer.nvidia.com/compute/cuda/10.0/Prod/local_installers/cuda_10.0.130_410.48_linux
sudo sh cuda_10.0.130_410.48_linux

insert image description here

Add environment variables and add the suggestions in the above figure to the .bashrc file

Please make sure that

PATH includes /usr/local/cuda-11.4/bin
LD_LIBRARY_PATH includes /usr/local/cuda-11.4/lib64, or,
add /usr/local/cuda-11.4/lib64 to /etc/ld.so.conf and run ldconfig as root
vim ~/.bashrc
#Add path export PATH=$PATH:/usr/local/cuda-11.4/bin
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda-11.4/lib64
#Make the environment effectivesource ~/.bashrc

Check nvcc -V

insert image description here

cudatoolkit

sudo apt install nvidia-cuda-toolkit

4. Install cudnn

Install cudnn

https://developer.nvidia.com/rdp/cudnn-download

insert image description here

wget https://developer.download.nvidia.cn/compute/machine-learning/cudnn/secure/8.2.2/11.4_07062021/Ubuntu18_04-x64/libcudnn8_8.2.2.26-1%2Bcuda11.4_amd64.deb?aJLLhXbzztwE4iizwf68uvg1s73kk4KKBGqv6B0UkO9HhnOhOsGHlyo1Br5CWc0nAIJLmc6C5SkLYqbdQqdZBoAdcVQgBTmWKXJXigR7roUeXd0VIKUuM57UKWMp3BUQgr6SQ4kkGnRRtUJ5mJt
dpkg -i libcudnn8_8.2.2.26-1+cuda11.4_amd64.deb

insert image description here

5. Install anaconda

wget https://mirror.tuna.tsinghua.edu.cn/anaconda/archive/Anaconda3-2021.05-Linux-x86_64.sh

insert image description here

Add environment variables

vim ~/.bashrc
export PATH="/usr/local/anaconda3/bin:$PATH"
source ~/.bashrc

insert image description here

Replace anaconda source

"""Change Tsinghua conda source"""
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
conda config --set show_channel_urls yes
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/

Check the tensorflow version

insert image description here

pip install tensorflow-gpu==2.2.0 -i https://pypi.tuna.tsinghua.edu.cn/simple

Test the installed tensorflow

import tensorflow as tf
print(tf.test.is_gpu_available())
tf.__version__
tf.__path__

insert image description here

The reason for the above error is that the cuda version is too high. You need to choose version 10.1

insert image description here

The reason for the above error is that the cudnn version is too high. You need to choose version 7.6.5

The default Python2 is changed to Python3

apt-get install python3.7
sudo update-alternatives --install /usr/bin/python python /usr/bin/python2 100
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3 150
sudo apt install python3-pip

The above is the detailed content of the tutorial on installing graphics driver and cuda in Ubuntu. For more information about installing graphics driver and cuda in Ubuntu, please pay attention to other related articles on 123WORDPRESS.COM!

You may also be interested in:
  • Install nvidia graphics driver under Ubuntu (simple installation method)
  • How to check whether the graphics driver has been successfully installed in Ubuntu
  • Detailed tutorial on installing nvidia driver + CUDA + cuDNN in Ubuntu 16.04
  • How to install RTX2080 Nvidia graphics card driver in Ubuntu18.04.2
  • Tutorial on installing Nvidia graphics card driver in Ubuntu 18.04 (with pictures and text)

<<:  Detailed explanation of :key in VUE v-for

>>:  A brief discussion on Flex layout and scaling calculation

Recommend

Vue implements simple data two-way binding

This article example shares the specific code of ...

How to install Windows Server 2008 R2 on Dell R720 server

Note: All pictures in this article are collected ...

Split and merge tables in HTML (colspan, rowspan)

The code demonstrates horizontal merging: <!DO...

In-depth explanation of MySQL user account management and permission management

Preface The MySQL permission table is loaded into...

W3C Tutorial (1): Understanding W3C

W3C, an organization founded in 1994, aims to unl...

How to deploy gitlab using Docker-compose

Docker-compose deploys gitlab 1. Install Docker I...

Solve the docker.socket permission problem of vscode docker plugin

Solution: Kill all .vscode related processes in t...

Tips for importing csv, excel or sql files into MySQL

1. Import csv file Use the following command: 1.m...

Complete steps to use vue-router in vue3

Preface Managing routing is an essential feature ...

Vue implements tab label (label exceeds automatic scrolling)

When the created tab label exceeds the visible ar...

Introduction to using data URI scheme to embed images in web pages

The data URI scheme allows us to include data in a...

How to query the latest transaction ID in MySQL

Written in front: Sometimes you may need to view ...

Virtual Box tutorial diagram of duplicating virtual machines

After getting used to VM, switching to BOX is a l...