sudo apt-get remove --purge nvidia*
具体方法有很多种,可以参考此帖:https://www.zhihu.com/question/68565667
本人亲测使用的是:
1、在/etc/modprobe.d/路径添加并修改配置文件
sinc-lab@sinclab-desktop:~$ sudo touch /etc/modprobe.d/blacklist-nouveau.conf
sinc-lab@sinclab-desktop:~$ sudo nano /etc/modprobe.d/blacklist-nouveau.conf
在blacklist-nouveau.conf文件中添加这几句话:
blacklist nouveau
options nouveau modeset=0
2、 重新生成 kernel initramfs
sinc-lab@sinclab-desktop:~$ sudo update-initramfs -u
update-initramfs: Generating /boot/initrd.img-4.4.0-21-generic
W: Possible missing firmware /lib/firmware/ast_dp501_fw.bin for module ast
3、重启
sinc-lab@sinclab-desktop:~$ sudo reboot
4、最终确认nouveau是否被拉黑
输入lsmod | grep nouveau查看,没有输出即禁止成功
拉黑前:
sinc-lab@sinclab-desktop:~$ lsmod | grep nouveau
nouveau 1495040 0
mxm_wmi 16384 1 nouveau
video 40960 1 nouveau
ttm 98304 2 ast,nouveau
drm_kms_helper 139264 2 ast,nouveau
i2c_algo_bit 16384 3 ast,igb,nouveau
drm 360448 6 ast,ttm,drm_kms_helper,nouveau
wmi 20480 2 mxm_wmi,nouveau
拉黑后:
sinc-lab@sinclab-desktop:~$ lsmod | grep nouveau
sinc-lab@sinclab-desktop:~$ sudo service lightdm stop
工作站reboot后analt + ctrl + F1进入textmode模式,输入用户和密码后,禁用lightdm服务:
sinc-lab@sinclab-desktop:~$ sudo service lightdm stop
进入NVIDIA显卡驱动官网下载驱动(这种下载方式貌似只提供最新的驱动版本下载),切换到驱动.run文件路径,使用sudo ./NVIDIA*.run -no-opengl-files安装NVIDIA驱动(后面的-no-opengl-files不能省掉,否则会造成进不去桌面,卡在登陆界面循环):
sinc-lab@sinclab-desktop:/media/vslyu/home/sinc-lab$ sudo ./Documents/ubantu服务器软件/NVIDIA-Linux-x86_64-390.59.run -no-opengl-files
Verifying archive integrity... OK
Uncompressing NVIDIA Accelerated Graphics Driver for Linux-x86_64 390.59........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................
跟着提示跑完安装流程即可。(可能会碰到 “The CC version check failed”的问题,思考过程另见博文——“安装NVIDIA驱动时碰到 “The CC version check failed”以及延伸的兼容性思考”)
安装完成后,输入nvidia-smi命令查看显卡信息是否存在,存在即说明成功打上驱动:
sinc-lab@sinclab-desktop:/media/vslyu/home/sinc-lab/Downloads$ nvidia-smi
Tue Sep 11 17:23:40 2018
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 384.130 Driver Version: 384.130 |
|-------------------------------+----------------------+----------------------+
| GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |
|===============================+======================+======================|
| 0 GeForce GTX 108... Off | 00000000:02:00.0 Off | N/A |
| 23% 41C P0 62W / 250W | 0MiB / 11172MiB | 0% Default |
+-------------------------------+----------------------+----------------------+
| 1 GeForce GTX 108... Off | 00000000:03:00.0 Off | N/A |
| 24% 44C P0 61W / 250W | 0MiB / 11172MiB | 0% Default |
+-------------------------------+----------------------+----------------------+
| 2 GeForce GTX 108... Off | 00000000:82:00.0 Off | N/A |
| 23% 41C P0 61W / 250W | 0MiB / 11172MiB | 0% Default |
+-------------------------------+----------------------+----------------------+
| 3 GeForce GTX 108... Off | 00000000:83:00.0 Off | N/A |
| 23% 39C P0 59W / 250W | 0MiB / 11172MiB | 2% Default |
+-------------------------------+----------------------+----------------------+
+-----------------------------------------------------------------------------+
| Processes: GPU Memory |
| GPU PID Type Process name Usage |
|=============================================================================|
| No running processes found |
+-----------------------------------------------------------------------------+
(ps:之前安装的Driver Version为390.87,单这里输出的 Driver Version为384.130,这是因为我这里贴的图是安装自带NVIDIA Driver的本地cuda-repo-ubuntu1604-9-0-local_9.0.176-1_amd64.deb文件后的输出结果)
参照NVIDIA的NVIDIA CUDA Installation Guide for Linux,按照要求一步一步进行确认,推荐使用.deb文件进行安装,使用.run文件进行安装时之前在配置TensorRT遇到过一个坑(不好意思,这个坑具体是什么我忘了),
在线安装的deb(安装在线的deb会提醒选择Driver Version的是否安装、是否需要更新等信息):
sudo dpkg -i cuda-repo-ubuntu1604_9.0.176-1_amd64.deb
~$ sudo apt-key adv --fetch-keys http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64/7fa2af80.pub
~$ sudo apt-get update
~$ sudo apt-get install cuda
本地安装的deb(安装在线的deb不会提醒选择Driver Version的是否安装、是否需要更新等信息,默认配置本地自带的Driver,故安装本地的deb文件需要先配置Driver,安装本地的deb文件会自动安装配置好):
sinc-lab@sinclab-desktop:/media/vslyu/home/sinc-lab/Downloads$ sudo dpkg -i cuda-repo-ubuntu1604-9-0-local_9.0.176-1_amd64.deb
~$ sudo apt-key adv --fetch-keys http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64/7fa2af80.pub
~$ sudo apt-get update
~$ sudo apt-get install cuda
注意添加.pub公钥后一定要update一下,建立好apt-cache信息:
sinc-lab@sinclab-desktop:/media/vslyu/home/sinc-lab/Downloads$ sudo apt-get update
Get:1 file:/var/cuda-repo-9-0-local InRelease
Ign:1 file:/var/cuda-repo-9-0-local InRelease
Get:2 file:/var/cuda-repo-9-0-local Release [574 B]
Hit:3 http://mirrors.hust.edu.cn/ubuntu xenial InRelease
Get:2 file:/var/cuda-repo-9-0-local Release [574 B]
Get:4 http://mirrors.hust.edu.cn/ubuntu xenial-security InRelease [107 kB]
Get:5 http://mirrors.hust.edu.cn/ubuntu xenial-updates InRelease [109 kB]
Hit:6 http://mirrors.hust.edu.cn/ubuntu xenial-proposed InRelease
Get:7 http://mirrors.hust.edu.cn/ubuntu xenial-backports InRelease [107 kB]
Get:9 http://mirrors.hust.edu.cn/ubuntu xenial-security/universe Sources [73.6 kB]
Get:10 http://mirrors.hust.edu.cn/ubuntu xenial-security/main amd64 DEP-11 Metadata [67.7 kB]
Get:11 http://mirrors.hust.edu.cn/ubuntu xenial-security/main DEP-11 64x64 Icons [68.0 kB]
Get:12 http://mirrors.hust.edu.cn/ubuntu xenial-security/universe amd64 Packages [370 kB]
Get:13 http://mirrors.hust.edu.cn/ubuntu xenial-security/universe amd64 DEP-11 Metadata [107 kB]
Get:14 http://mirrors.hust.edu.cn/ubuntu xenial-security/universe DEP-11 64x64 Icons [142 kB]
Get:15 http://mirrors.hust.edu.cn/ubuntu xenial-updates/universe Sources [220 kB]
Get:16 http://mirrors.hust.edu.cn/ubuntu xenial-updates/main amd64 DEP-11 Metadata [320 kB]
Get:17 http://mirrors.hust.edu.cn/ubuntu xenial-updates/main DEP-11 64x64 Icons [227 kB]
Get:18 http://mirrors.hust.edu.cn/ubuntu xenial-updates/universe amd64 Packages [683 kB]
Get:19 http://mirrors.hust.edu.cn/ubuntu xenial-updates/universe i386 Packages [624 kB]
Get:20 http://mirrors.hust.edu.cn/ubuntu xenial-updates/universe amd64 DEP-11 Metadata [247 kB]
Get:21 http://mirrors.hust.edu.cn/ubuntu xenial-updates/universe DEP-11 64x64 Icons [335 kB]
Get:22 http://mirrors.hust.edu.cn/ubuntu xenial-updates/multiverse amd64 DEP-11 Metadata [5,960 B]
Get:23 http://mirrors.hust.edu.cn/ubuntu xenial-updates/multiverse DEP-11 64x64 Icons [14.3 kB]
Get:24 http://mirrors.hust.edu.cn/ubuntu xenial-backports/main amd64 DEP-11 Metadata [3,328 B]
Get:25 http://mirrors.hust.edu.cn/ubuntu xenial-backports/universe amd64 DEP-11 Metadata [5,100 B]
Fetched 3,835 kB in 0s (4,534 kB/s)
Reading package lists... Done
sinc-lab@sinclab-desktop:/media/vslyu/home/sinc-lab/Downloads$
在环境变量中添加CUDA,sudo权限打开~/.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}}
再激活、加载一下配置:
sinc-lab@sinclab-desktop:/media/vslyu/home/sinc-lab/Downloads$ source ~/.bashrc
sinc-lab@sinclab-desktop:/media/vslyu/home/sinc-lab/Downloads$ sudo ldconfig
sinc-lab@sinclab-desktop:/media/vslyu/home/sinc-lab/Downloads$