KaliLinux 安装Nvidia闭源驱动

查看主机是否存在nvidia显卡

1
lspci -k | grep -A 2 -E "(VGA|3D)"

00:02.0 VGA compatible controller: Intel Corporation 3rd Gen Core processor Graphics Controller (rev 09)
Subsystem: Lenovo 3rd Gen Core processor Graphics Controller
Kernel driver in use: i915

01:00.0 3D controller: NVIDIA Corporation GK208M [GeForce GT 740M] (rev a1)
Subsystem: Lenovo GK208M [GeForce GT 740M]
Kernel driver in use: nvidia

更新系统并重启

1
2
apt update && apt dist-upgrade -y
reboot

禁用nvidia开源驱动nouveau

1
vim /etc/modprobe.d/blacklist-libnfc.conf

blacklist-libnfc.conf最后添加

1
2
blacklist nouveau
options nouveau modeset=0

安装 linux-headers

1
apt install linux-headers-$(uname -r)

安装nvidia驱动

1
apt-get install nvidia-kernel-dkms nvidia-cuda-toolkit nvidia-driver

安装bumblebee primus

“Bumblebee 致力于使 NVIDIA Optimus 在 GNU/Linux 系统上可用,实现两块不同的供电配置的显卡同时插入使用,共享同一个 framebuffer。”

1
apt install bumblebee-nvidia primus

开机自启动bumblebee服务

1
#systemctl enable bumblebeed

添加当前用户到bumblebee组

1
adduser root bumblebee

改变以下 bumblebee.conf 设置:

1
vim /etc/bumblebee/bumblebee.conf 
1
2
KeepUnusedXServer=true
Driver=nvidia

接下来修改 vim /etc/bumblebee/xorg.conf.nvidia
下面这条指令可以获取显卡的总线的ID

1
lspci -k | grep -A 2 -E "(VGA|3D)"

00:02.0 VGA compatible controller: Intel Corporation 3rd Gen Core processor Graphics Controller (rev 09)
Subsystem: Lenovo 3rd Gen Core processor Graphics Controller
Kernel driver in use: i915

01:00.0 3D controller: NVIDIA Corporation GK208M [GeForce GT 740M] (rev a1)
Subsystem: Lenovo GK208M [GeForce GT 740M]
Kernel driver in use: nvidia

我的笔记本nvidia的总线ID为01:00.0

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
Section "ServerLayout" 
Identifier "Layout0"
Option "AutoAddDevices" "false"
Option "AutoAddGPU" "false"
EndSection

Section "Device"
Identifier "DiscreteNvidia"
Driver "nvidia"
VendorName "NVIDIA Corporation"

# If the X server does not automatically detect your VGA device,
# you can manually set it here.
# To get the BusID prop, run `lspci | egrep 'VGA|3D'` and input the data
# as you see in the commented example.
# This Setting may be needed in some platforms with more than one
# nvidia card, which may confuse the proprietary driver (e.g.,
# trying to take ownership of the wrong device). Also needed on Ubuntu 13.04.
BusID "PCI:01:00:0"

# Setting ProbeAllGpus to false prevents the new proprietary driver
# instance spawned to try to control the integrated graphics card,
# which is already being managed outside bumblebee.
# This option doesn't hurt and it is required on platforms running
# more than one nvidia graphics card with the proprietary driver.
# (E.g. Macbook Pro pre-2010 with nVidia 9400M + 9600M GT).
# If this option is not set, the new Xorg may blacken the screen and
# render it unusable (unless you have some way to run killall Xorg).
Option "ProbeAllGpus" "false"

Option "NoLogo" "true"
Option "UseEDID" "false"
Option "UseDisplayDevice" "none"
EndSection

把BusID这一行的注释去掉,修改里面的PCI号(你获取到独显BUSID号码),值得注意的是,获取到的ID号最后一位必须为冒号.

也就是PCI:01:00:0

重启检测驱动是否安装成功

我这里主要使用hashcat破解密码,这里使用hashcat测试nvidia驱动是否安装成功

1
hashcat -I

也可以安装 mesa-demos 并使用 glxgears 测试 Bumblebee 是否工作:

1
$ optirun glxgears -info

如果失败,尝试下列命令:
64位系统:

1
$ optirun glxspheres64

32位系统:

1
$ optirun glxspheres32

如果一个内有动画的窗口出现,那么 Optimus 和 Bumblebee 正在工作。


本博客所有文章除特别声明外,均采用 CC BY-SA 4.0 协议 ,转载请注明出处!