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

Solution to the same IP after cloning Ubuntu 18 virtual machine

Preface I recently used a virtual machine to inst...

MySQL tutorial DML data manipulation language example detailed explanation

Table of contents 1. Data Manipulation Language (...

Implementation of check constraints in MySQL 8.0

Hello everyone, I am Tony, a teacher who only tal...

Do you know what are the ways to jump routes in Vue?

Table of contents The first method: router-link (...

How to add website icon?

The first step is to prepare an icon making softwa...

Is the tag li a block-level element?

Why can it set the height, but unlike elements lik...

MySQL Billions of Data Import, Export and Migration Notes

I have been taking a lot of MySQL notes recently,...

Detailed explanation of the binlog log analysis tool for monitoring MySQL: Canal

Canal is an open source project under Alibaba, de...

Use Vue3+Vant component to implement App search history function (sample code)

I am currently developing a new app project. This...

Using HTML+CSS to track mouse movement

As users become more privacy-conscious and take m...

Pure CSS to achieve automatic rotation effect of carousel banner

Without further ado, let’s get straight to the co...

How to implement nested if method in nginx

Nginx does not support nested if statements, nor ...

Introduction to Vue3 Composition API

Table of contents Overview Example Why is it need...

About Generics of C++ TpeScript Series

Table of contents 1. Template 2. Generics 3. Gene...