Tutorial on installing Ubuntu 20.04 and NVIDIA drivers

Tutorial on installing Ubuntu 20.04 and NVIDIA drivers

Install Ubuntu 20.04 Install NVIDIA drivers Configure Pytouch and tensorflow environment

Local environment: Dell G3 3579
win10, the system is on a 128 SSD

Install Ubuntu 20.04

1 Press F2 to enter BIOS
2 security boot settings disable
3 References
https://www.jb51.net/article/173277.htm

insert image description here

Install NVIDIA Driver

When installing the driver, first disable nouveau
Then uninstall the original nvidia driver (if any)
refer to:
https://www.jb51.net/article/171959.htm
But after installing this situation
There is output in nvidia-smi, and it is reflected in nvidia-settings. A shortcut icon is also generated. However, after restarting to take effect, in Settings->About: the graphics card has changed from the original integrated graphics card 630 to lvib or something. Although it does not affect the establishment of the approved learning environment, I always feel that it will hang in the future. There is another situation. After the driver is installed, in Settings->About: the graphics card shows GTX1060. However, every time I start or shut down the computer, it displays: dev/sda5 clean…dev/sda6 clean. It shuts down after 2 seconds, and the same happens when I start up.
There is another situation: the environment is set up, the drivers and so on are all ready, but a command, when installing NetEase Cloud Music, needs to get some dependencies, and then a line of command is passed, and dev/sda6 clean flashes endlessly when booting. ctro-alt-f1 can open tty, but there is no time to enter the username and password, and tty crashes in less than 1 second. Then I couldn't enter the system. Finally reinstall the system now:
After installing the Ubuntu system, do not update anything and do not disable nouveau. The first thing is to install the driver directly.

insert image description here

After restarting, nothing happened.

Building pytouch

Install miniconda3,
Change to USTC, Tsinghua source
conda create -n pytouch python=3.7
conda activate pytouch
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
conda install pytorch=0.4.1 torchvision cuda90

Install PyCharm

insert image description here

Click tools->create desktop entry to directly generate shortcut keys and set the compiler to pytouch
Fill in the code to test the use of GPU:

import torch
flag = torch.cuda.is_available()
print(flag)

ngpu=1
# Decide which device we want to run on
device = torch.device("cuda:0" if (torch.cuda.is_available() and ngpu > 0) else "cpu")
print(device)
print(torch.cuda.get_device_name(0))
print(torch.rand(3,3).cuda()) 
# True
# cuda:0
# GeForce GTX 1060
# tensor([[0.5772, 0.5287, 0.0946],
# [0.9525, 0.7855, 0.1391],
# [0.6858, 0.5143, 0.8188]], device='cuda:0')

Install tensorflow14

import tensorflow as tf
from tensorflow.python.client import device_lib
print(device_lib.list_local_devices())
import warnings
warnings.filterwarnings("ignore")
hello = tf.constant("Hello, Tensorflow")
print(hello)
a=tf.constant([1.0,2.0]) #define constant b=tf.constant([3.4,4.0])
result1=a+b
print("a+b=",result1)
c = tf.constant([[3.0],[1.4]])
result2=a+c
sess = tf.Session()
print("result1:",result1)#The result is a tensor of "add:0", and the shape has only one element, that is, the dimension is 1
# 2 means the first dimension has two elements and they are floating point type try:
 print(sess.run(result1))
 print("result2:",result2)
 print(sess.run(result2))
 print(sess.run(hello))
except:
 #Exception handling print("Exception")
finally:
 #Close the session and release resources sess.close() 

insert image description here

Summarize

This is the end of this article about installing Ubuntu 20.04 and installing NVIDIA drivers. For more information about installing Ubuntu 20.04 NVIDIA drivers, please search for previous articles on 123WORDPRESS.COM or continue to browse the related articles below. I hope you will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • How to install RTX2080 Nvidia graphics card driver in Ubuntu18.04.2
  • Install nvidia graphics driver under Ubuntu (simple installation method)
  • Detailed tutorial on installing nvidia driver + CUDA + cuDNN in Ubuntu 16.04
  • Detailed tutorial on installing Docker and nvidia-docker on Ubuntu 16.04
  • Install Nvidia driver in Ubuntu 18 to solve black screen and adjust resolution problem
  • Tutorial on installing Nvidia graphics card driver in Ubuntu 18.04 (with pictures and text)

<<:  Detailed explanation of MySQL string concatenation function GROUP_CONCAT

>>:  Vue implements user login and token verification

Recommend

Detailed explanation of JS browser storage

Table of contents introduction Cookie What are Co...

Detailed explanation of the usage of the ESCAPE keyword in MySQL

MySQL escape Escape means the original semantics ...

HTML tag overflow processing application

Use CSS to modify scroll bars 1. Overflow setting...

How to use vuex in Vue project

Table of contents What is Vuex? Vuex usage cycle ...

How to connect idea to docker to achieve one-click deployment

1. Modify the docker configuration file and open ...

Detailed Explanation of JavaScript Framework Design Patterns

Table of contents mvc mvp mvvm The source of Vue ...

Detailed explanation of JavaScript Promise and Async/Await

Table of contents Overview Four examples Example ...

MySQL 5.7.17 Compressed Version Installation Notes

This article shares the installation steps of MyS...

10 skills that make front-end developers worth millions

The skills that front-end developers need to mast...

MySQL 5.7.20 installation and configuration method graphic tutorial (win10)

This article shares the installation and configur...

Some questions about hyperlinks

I am very happy to attend this episode of potato ...

The use and difference between JavaScript pseudo-array and array

Pseudo-arrays and arrays In JavaScript, except fo...

Build a Docker private warehouse (self-signed method)

In order to centrally manage the images we create...