Install Ubuntu 20.04 Install NVIDIA driver to configure Pytouch and tensorflow environment
Native environment: Dell G3 3579
win10, the system is on 128 solid state drives
1 Boot and press F2 to enter BIOS
2 security boot set disable
3 reference
https://www.zalou.cn/article/173277.htm
First install the driver, first prohibit nouveau
Then uninstall the original nvidia driver (if any)
reference:
https://www.zalou.cn/article/171959.htm
But this happens after installation
nvidia-smi has output, nvidia-settings has reflection, and shortcut icons are also generated
But after the restart takes 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, it always feels that it will hang in the future
In another case, after installing the driver, go to Settings->About: The graphics card displays GTX1060. But every time it is turned on or off, it shows: dev/sda5 clean…
dev/sda6 clean. After 2s, turn off the machine, the same is true for the startup.
Another situation is that the environment is set up, and the drivers are good, but a command, when installing NetEase Yunyue, what dependencies should be made, and then a command
Go, dev/sda6 clean flashes infinitely after booting. ctro-alt-f1 can open the tty, but the user name and password are too late to enter, and the tty flashes back and it takes less than 1s. Then can not enter the system.
Finally reinstall the system
right now:
After installing the ubuntu system, do not update anything, and do not ban nouveau. The first thing is to install the driver directly,
After restarting, nothing happened.
Install miniconda3,
Replaced by China University of Science and Technology, Tsinghua Yuan
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
Click tools->create desktop entry to directly generate shortcut keys
Set the compiler to pytouch
Fill in the code test using 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 display result is "add:0"Tensor, shape has only one element, that is, the dimension is 1
# 2 Indicates that the first dimension has two elements and is floating point
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()
to sum up
This is the end of this article about installing Ubuntu 20.04 and installing NVIDIA driver tutorials. For more related installation of Ubuntu 20.04 NVIDIA driver content, please search for previous articles on ZaLou.Cn or continue to browse related articles below. Hope everyone Support ZaLou.Cn a lot in the future!
Recommended Posts