原本就對Linux不熟悉,通過幾天慘痛的教訓,參考了不知道多少篇文章,終於把環境裝好了,每篇文章或多或少都有一些用,但沒有一篇完整的能解決我安裝過程碰到的問題,因此決定仍是本身寫一篇我安裝過程的教程,有些參考的文章會給出原地址,比較大衆的教程就沒有給出了。html
本文寫於2018年7月27日,注意下時效性,有問題歡迎留言linux
系統下載地址: http://releases.ubuntu.com/16.04/ ubuntu
下載64位系統:ubuntu-16.04.4-desktop-amd64.isobash
cd /etc/apt/ sudo cp sources.list sources.list.bak sudo gedit sources.list
deb http://mirrors.ustc.edu.cn/ubuntu/ xenial main restricted universe multiverse deb http://mirrors.ustc.edu.cn/ubuntu/ xenial-security main restricted universe multiverse deb http://mirrors.ustc.edu.cn/ubuntu/ xenial-updates main restricted universe multiverse deb http://mirrors.ustc.edu.cn/ubuntu/ xenial-proposed main restricted universe multiverse deb http://mirrors.ustc.edu.cn/ubuntu/ xenial-backports main restricted universe multiverse deb-src http://mirrors.ustc.edu.cn/ubuntu/ xenial main restricted universe multiverse deb-src http://mirrors.ustc.edu.cn/ubuntu/ xenial-security main restricted universe multiverse deb-src http://mirrors.ustc.edu.cn/ubuntu/ xenial-updates main restricted universe multiverse deb-src http://mirrors.ustc.edu.cn/ubuntu/ xenial-proposed main restricted universe multiverse deb-src http://mirrors.ustc.edu.cn/ubuntu/ xenial-backports main restricted universe multiverse
sudo apt-get update sudo apt-get upgrade
1)打開終端,先刪除舊的驅動:網絡
sudo apt-get purge nvidia*
2)禁用自帶的 nouveau nvidia驅動post
lsmod | grep nouveau
sudo gedit /etc/modprobe.d/blacklist-nouveau.conf
blacklist nouveau options nouveau modeset=0
sudo update-initramfs -u
lsmod | grep nouveau
sudo service lightdm stop
cd Downloads sudo sh NVIDIA-Linux-x86_64-390.42.run --no-opengl-files
sudo /etc/init.d/lightdm start //打開圖形界面 sudo mokutil --import /usr/share/nvidia/nvidia*.der //必須加上 sudo
sudo reboot //重啓
nvidia-smi
nvidia-settings
sudo service lightdm stop
cd Downloads sudo sh cuda_9.0.176_384.81_linux.run
Do you accept the previously read EULA? accept/decline/quit: accept Install NVIDIA Accelerated Graphics Driver for Linux-x86_64 384.81? (y)es/(n)o/(q)uit: n Install the CUDA 9.0 Toolkit? (y)es/(n)o/(q)uit: y Enter Toolkit Location [ default is /usr/local/cuda-9.0 ]: Do you want to install a symbolic link at /usr/local/cuda? (y)es/(n)o/(q)uit: y Install the CUDA 9.0 Samples? (y)es/(n)o/(q)uit: y
sudo service lightdm start //打開圖形界面 sudo gedit /etc/profile
export PATH=/usr/local/cuda-9.0/bin:$PATH export LD_LIBRARY_PATH=/usr/local/cuda-9.0/lib64$LD_LIBRARY_PATH
sudo ldconfig sudo reboot
查看版本
nvcc --version
編譯例子測試 cd /usr/local/cuda-9.0/samples/1_Utilities/deviceQuery sudo make ./deviceQuery
編譯例子的時候若是報錯顯示:CUDA driver version is insufficient for CUDA runtime version 解決方法卸載從新安裝參考文章:https://www.cnblogs.com/wolflzc/p/9117291.html測試
sudo apt-get remove cuda sudo apt-get autoclean sudo apt-get remove cuda* 而後在目錄切換到/esr/local/下 cd /usr/local/ sudo rm -r cuda-9.2
sudo gedit ~/.bashrc
export PATH=/usr/local/cuda-9.0/bin${PATH:+:${PATH}} export LD_LIBRARY_PATH=/usr/local/cuda-9.0/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
sudo gedit /etc/profile
export PATH=/usr/local/cuda/bin:$PATH
sudo gedit /etc/ld.so.conf.d/cuda.conf
/usr/local/cuda/lib64
sudo ldconfig
sudo service lightdm stop
tar -zxvf cudnn-9.0-linux-x64-v7.tgz cd cuda sudo cp lib64/lib* /usr/local/cuda/lib64/ sudo cp include/cudnn.h /usr/local/cuda/include/
cd /usr/local/cuda/lib64/ sudo chmod +r libcudnn.so.7.0.5 //本身查看.so的版本 對應更改 sudo ln -sf libcudnn.so.7.0.5 libcudnn.so.7 sudo ln -sf libcudnn.so.7 libcudnn.so sudo ldconfig
sudo service lightdm start