$ sudo apt-get update
$ sudo apt-get upgrade
Download Nvidia Drivers: [Nvidia Link]
$ sudo apt-get purge nvidia*
$ sudo vim /etc/modprobe.d/blacklist-nouveau.conf
blacklist nouveau
options nouveau modeset=0
$ sudo reboot
$ lsmod | grep nouveau
Ctrl + Alt + F1-( Enter virtual consoles )进入tty1命令行界面
Ctrl + Alt + F7-( Return back to GUI )回到桌面系统界面
$ sudo service lightdm stop
$ sudo chmod a+x NVIDIA-Linux-x86_64-390.87.run
$ sudo ./NVIDIA-Linux-x86_64-390.87.run -no-opengl-files -no-x-check -no-nouveau-check
- -no-opengl-files 只安装驱动文件,不安装OpenGL文件 (no install OpenGL file)
- -no-x-check 安装驱动时不检查X服务器 (no check X server)
- -no-nouveau-check 安装驱动时不检查nouveau模块 (no check nouveau module)
“Would you like to run the nvidia-xconfig utility to automatically update your X configuration file...”
Choose No.
After above: $sudo reboot
$ nvidia-smi
Download CUDA: cuda_9.0.176_384.81_linux.run [CUDA Link]
$ sudo ./cuda_9.0.176_384.81_linux.run --no-opengl-libs
...
[accept] #同意安装 [n] #安装Driver,将自动安装CUDA版本相匹配的Nvidia驱动, - No install Driver [y] #安装CUDA Toolkit install <Enter> #安装到默认目录 [y] #创建安装目录的软链接 [n] #不复制Samples,因为在安装目录下有/samples
export PATH="/usr/local/cuda/bin:$PATH"
export LD_LIBRARY_PATH="/usr/local/cuda/lib64:$LD_LIBRARY_PATH"
$ source .bashrc
$ nvcc -V
$ cd /usr/local/cuda-9.0/samples/1_Utilities/deviceQuery
$ sudo make
$ ./deviceQuery
$ cd ../bandwidthTest
$ sudo make
$ ./bandwidthTest
$ cd /usr/local/cuda-9.0/samples/1_Utilities/deviceQuery
$ sudo make
$ ./deviceQuery
$ cd ../bandwidthTest
$ sudo make
$ ./bandwidthTest
Download Version: cuDNN v7.1.4 (May 16, 2018), for CUDA 9.0 [cuDNN Link]
$ tar -zxvf cudnn-9.0-linux-x64-v7.1.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.1.4
$ sudo ln -sf libcudnn.so.7.1.4 libcudnn.so.7
$ sudo ln -sf libcudnn.so.7 libcudnn.so
$ sudo ldconfig
注意这里 tensorflow-gpu 的版本 cuda 会报错误
CUDA 9.0 - tensorflow-gpu==1.10.0
CUDA 10.0 - tensorflow-gpu==1.13.1
$ sudo pip3 uninstall tensorflow
$ pip3 install --user tensorflow-gpu==1.10.0
$ sudo apt-get remove nvidia-*
$ sudo apt-get autoremove
$ sudo nvidia-uninstall
NVIDIA-SMI has failed because it couldn't communicate with the NVIDIA driver. Make sure that the latest NVIDIA driver is installed and running issue
$ uname -a
#目前使用版本为 4.15
Linux CAI 4.15.0-50-generic #54~16.04.1-Ubuntu SMP Wed May 8 15:55:19 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
若版本高于 4.10 必须升级, 降级方法如下
wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v4.15.7/linux-headers-4.15.7-041507_4.15.7-041507.201802280530_all.deb
wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v4.15.7/linux-headers-4.15.7-041507-generic_4.15.7-041507.201802280530_amd64.deb
wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v4.15.7/linux-image-4.15.7-041507-generic_4.15.7-041507.201802280530_amd64.deb
sudo dpkg -i *.deb
升级完成后 nvidia-smi 出现 GPU 使用狀況栏可不用重新安装 Driver, 若未出现可按步骤重新安装 Driver
$ lspci | grep 'VGA'
#找到卡后,显示显卡讯息
01:00.0 VGA compatible controller: NVIDIA Corporation Device 1b06 (rev a1)
a. 开机后, 进入Bios 设定画面(若是Acer的电脑, 按Del 或是F2 即可进入Bios)
b. 改成disable 后, 重新开机
$ sudo gedit /etc/X11/xorg.conf
Section "Monitor"
Identifier "Configured Monitor"
Modeline "1920x1080_60.00" 173.00 1920 2048 2248 2576 1080
1083 1088 1120 -hsync +vsync
Option "PreferredMode" "1920x1080_60.00"
EndSection
Section "Screen"
Identifier "Default Screen"
Monitor "Configured Monitor"
Device "Configured Video Device"
EndSection
Section "Device"
Identifier "Configured Video Device"
EndSection
$ cvt 1920 1080
# 1920x1080 59.96 Hz (CVT 2.07M9) hsync: 67.16 kHz; pclk: 173.00 MHz
Modeline "1920x1080_60.00" 173.00 1920 2048 2248 2576 1080 1083 1088 1120 -hsync +vsync
$ sudo xrandr --newmode "1920x1080_60.00" 173.00 1920 2048 2248 2576 1080 1083 1088 1120 -hsync +vsync
$ sudo xrand --addmode [THE NAME OF YOUR DISPLAY] "1920x1080_60.00"
$ sudo xrand --output [THE NAME OF YOUR DISPLAY] --mode "1920x1080_60.00"
$ sudo apt-get purge nvidia*
$ cd /usr/local/cuda/bin
$ sudo ./uninstall_cuda_7.5.pl
$ sudo rm -rf /usr/local/cuda/include/cudnn.h
$ sudo rm -rf /usr/local/cuda/lib64/libcudnn
cd ~
mkdir .pip
sudo vim .pip/pip.conf
写入:
[global]
index-url = http://mirrors.aliyun.com/pypi/simple/
[install]
trusted-host = mirrors.aliyun.com
-
Ubuntu 18.04 - GTX 1080 / RTX 2080 CUDA 和 NVIDIA 驱动同时安装 [中文文档]
-
Ubuntu 16.04 - GTX 1080 / RTX 2080 CUDA 和 NVIDIA 驱动同时安装 [中文文档]
-
Ubuntu 16.04 - GTX 1080 / RTX 2080 CUDA 和 NVIDIA 驱动单独安装 [中文文档]