安裝Ubuntu20.04與安裝NVIDIA驅(qū)動(dòng)的教程
安裝Ubuntu 20.04 安裝NVIDIA 驅(qū)動(dòng) 配置Pytouch 和tensorflow環(huán)境
本機(jī)環(huán)境:戴爾G3 3579
win10 ,系統(tǒng)在128固態(tài)硬盤
安裝Ubuntu20.04
1開機(jī)按F2進(jìn)入BIOS
2 security boot 設(shè)置disable
3 參考
https://www.jb51.net/article/173277.htm
安裝NVIDIA驅(qū)動(dòng)
最開始安裝驅(qū)動(dòng),首先禁止nouveau
然后卸載原先的nvidia驅(qū)動(dòng)(如果有)
參考:
https://www.jb51.net/article/171959.htm
但是裝完出現(xiàn)這種情況
nvidia-smi有輸出,nvidia-settings有反映,而且還生成了快捷圖標(biāo)
但是重啟生效后,在設(shè)置->關(guān)于:顯卡由原來的集成顯卡630變成了lvib什么的
雖然不影響審定學(xué)習(xí)環(huán)境搭建但是總感覺以后會(huì)掛的
還有一種情況是 ,裝完成驅(qū)動(dòng)后,在設(shè)置->關(guān)于:顯卡顯示GTX1060。但是每次開機(jī)或者關(guān)機(jī)顯示:dev/sda5 clean …dev/sda6 clean.等2s后關(guān)機(jī),開機(jī)也是這樣。
還有一種情況是,環(huán)境搭建好了,驅(qū)動(dòng)什么的都好了,但是一個(gè)命令,當(dāng)時(shí)在安裝網(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ū)動(dòng),
重啟后,麻事情沒有。
搭建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
點(diǎn)擊tools->create desktop entry 直接生成快捷鍵
設(shè)置編譯器為pytouch
填寫代碼測(cè)試使用了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只有一個(gè)元素,即維度是1 # 2表示第一個(gè)維度有兩個(gè)元素,且是浮點(diǎn)型 try: print(sess.run(result1)) print("result2:",result2) print(sess.run(result2)) print(sess.run(hello)) except: #異常處理 print("Exception") finally: #關(guān)閉會(huì)話,釋放資源 sess.close()
總結(jié)
到此這篇關(guān)于安裝Ubuntu20.04與安裝NVIDIA驅(qū)動(dòng)的教程的文章就介紹到這了,更多相關(guān)安裝Ubuntu20.04 NVIDIA驅(qū)動(dòng)內(nèi)容請(qǐng)搜索本站以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持本站!
版權(quán)聲明:本站文章來源標(biāo)注為YINGSOO的內(nèi)容版權(quán)均為本站所有,歡迎引用、轉(zhuǎn)載,請(qǐng)保持原文完整并注明來源及原文鏈接。禁止復(fù)制或仿造本網(wǎng)站,禁止在非www.sddonglingsh.com所屬的服務(wù)器上建立鏡像,否則將依法追究法律責(zé)任。本站部分內(nèi)容來源于網(wǎng)友推薦、互聯(lián)網(wǎng)收集整理而來,僅供學(xué)習(xí)參考,不代表本站立場(chǎng),如有內(nèi)容涉嫌侵權(quán),請(qǐng)聯(lián)系alex-e#qq.com處理。