ubuntu安裝顯卡驅(qū)動(dòng)和cuda教程
寫在最前面:
最新的版本不一定是好的,合適的才是最好的,建議cuda10.1+cudnn7.6.5
1. 卸載原始的驅(qū)動(dòng)
#查看安裝的包 apt list --installed|grep -i nvidia #卸載包 apt-get purge nvidia*
2. 下載新顯卡驅(qū)動(dòng)
https://www.nvidia.cn/Download/index.aspx?lang=cn
復(fù)制下載鏈接,在系統(tǒng)中用wget下載
#下載 wget https://cn.download.nvidia.cn/tesla/470.57.02/NVIDIA-Linux-x86_64-470.57.02.run #安裝 sudo sh NVIDIA-Linux-x86_64-470.57.02.run
2.1 安裝顯卡驅(qū)動(dòng)
3 安裝cuda
選擇cuda版本,要和驅(qū)動(dòng)的cuda版本一致
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
添加環(huán)境變量,將上圖中的建議加到.bashrc文件中
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 #添加路徑 export PATH=$PATH:/usr/local/cuda-11.4/bin export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda-11.4/lib64 #使環(huán)境生效 source ~/.bashrc
查看nvcc -V
cudatoolkit
sudo apt install nvidia-cuda-toolkit
4. 安裝cudnn
安裝cudnn
https://developer.nvidia.com/rdp/cudnn-download
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
5. 安裝anaconda
wget https://mirror.tuna.tsinghua.edu.cn/anaconda/archive/Anaconda3-2021.05-Linux-x86_64.sh
添加環(huán)境變量
vim ~/.bashrc export PATH="/usr/local/anaconda3/bin:$PATH" source ~/.bashrc
替換anaconda源
"""更換清華conda源""" 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/
查看tensorflow版本
pip install tensorflow-gpu==2.2.0 -i https://pypi.tuna.tsinghua.edu.cn/simple
測試安裝的tensorflow
import tensorflow as tf print(tf.test.is_gpu_available()) tf.__version__ tf.__path__
上述報(bào)錯(cuò)原因是cuda版本太高了,要選擇10.1版本
上述報(bào)錯(cuò)原因是cudnn版本太高了,要選擇7.6.5版本
默認(rèn)Python2調(diào)整為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
以上就是ubuntu安裝顯卡驅(qū)動(dòng)和cuda教程的詳細(xì)內(nèi)容,更多關(guān)于ubuntu安裝顯卡驅(qū)動(dòng)和cuda的資料請(qǐng)關(guān)注腳本之家其它相關(guān)文章!
相關(guān)文章
Linux取消目錄的執(zhí)行權(quán)限的具體步驟
用戶對(duì)一個(gè)文件或目錄具有訪問權(quán)限,這些訪問權(quán)限決定了誰能訪問,以及如何范圍這些文件和目錄,本文給大家介紹了Linux取消目錄的執(zhí)行權(quán)限的具體步驟,并通過代碼示例講解的非常詳細(xì),需要的朋友可以參考下2024-10-10Linux之進(jìn)程的虛擬地址空間,邏輯地址和物理地址,進(jìn)程管理命令
這篇文章主要介紹了Linux之進(jìn)程的虛擬地址空間,邏輯地址和物理地址,進(jìn)程管理命令,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2023-03-03Ubuntu16.04環(huán)境下搭建FTP服務(wù)器的教程
這篇文章主要介紹了Ubuntu16.04搭建FTP服務(wù)器的教程,本文給大家介紹的非常詳細(xì),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2019-12-12