溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點(diǎn)擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

如何安裝Ubuntu與NVIDIA驅(qū)動

發(fā)布時間:2022-10-27 10:01:36 來源:億速云 閱讀:128 作者:iii 欄目:服務(wù)器

這篇文章主要介紹“如何安裝Ubuntu與NVIDIA驅(qū)動”的相關(guān)知識,小編通過實際案例向大家展示操作過程,操作方法簡單快捷,實用性強(qiáng),希望這篇“如何安裝Ubuntu與NVIDIA驅(qū)動”文章能幫助大家解決問題。

安裝ubuntu20.04

1開機(jī)按f2進(jìn)入bios
2 security boot 設(shè)置disable

如何安裝Ubuntu與NVIDIA驅(qū)動

安裝nvidia驅(qū)動

最開始安裝驅(qū)動,首先禁止nouveau
然后卸載原先的nvidia驅(qū)動(如果有)

但是裝完出現(xiàn)這種情況
nvidia-smi有輸出,nvidia-settings有反映,而且還生成了快捷圖標(biāo)
但是重啟生效后,在設(shè)置->關(guān)于:顯卡由原來的集成顯卡630變成了lvib什么的
雖然不影響審定學(xué)習(xí)環(huán)境搭建但是總感覺以后會掛的
還有一種情況是 ,裝完成驅(qū)動后,在設(shè)置->關(guān)于:顯卡顯示gtx1060。但是每次開機(jī)或者關(guān)機(jī)顯示:dev/sda5 clean …dev/sda6 clean.等2s后關(guān)機(jī),開機(jī)也是這樣。
還有一種情況是,環(huán)境搭建好了,驅(qū)動什么的都好了,但是一個命令,當(dāng)時在安裝網(wǎng)易云音月,要弄什么依賴,然后一行命令過去,開機(jī)無限閃現(xiàn)dev/sda6 clean 。ctro-alt-f1能打開tty,但是用戶名和密碼來不及輸入,tty閃退,1s不到。然后進(jìn)不了系統(tǒng)。最后重裝系統(tǒng)
現(xiàn)在:
裝完ubuntu系統(tǒng)后,什么更新都不要,也不要禁止nouveau。第一件事情直接裝驅(qū)動,

如何安裝Ubuntu與NVIDIA驅(qū)動

重啟后,麻事情沒有。

搭建pytouch

安裝miniconda3,
換中科大,清華源
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

安裝pycharm

如何安裝Ubuntu與NVIDIA驅(qū)動

點(diǎn)擊tools->create desktop entry 直接生成快捷鍵
設(shè)置編譯器為pytouch
填寫代碼測試使用了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')

安裝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]) #定義常數(shù)
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)#顯示結(jié)果是“add:0"的張量,shape只有一個元素,即維度是1
# 2表示第一個維度有兩個元素,且是浮點(diǎn)型
try:
 print(sess.run(result1))
 print("result2:",result2)
 print(sess.run(result2))
 print(sess.run(hello))
except:
 #異常處理
 print("exception")
finally:
 #關(guān)閉會話,釋放資源
 sess.close()

如何安裝Ubuntu與NVIDIA驅(qū)動

關(guān)于“如何安裝Ubuntu與NVIDIA驅(qū)動”的內(nèi)容就介紹到這里了,感謝大家的閱讀。如果想了解更多行業(yè)相關(guān)的知識,可以關(guān)注億速云行業(yè)資訊頻道,小編每天都會為大家更新不同的知識點(diǎn)。

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI