1、检查仓库源
确保仓库包含contrib和non-free部分。kali默认就有此部分。Debian可能需要自己手工添加,建议检查下为好
检查是否包含contrib和non-free

┌──(smoke㉿smoke-gs70-2pc-stealth)-[/etc/modprobe.d]
└─$ grep 'contrib non-free' /etc/apt/sources.list
deb http://http.kali.org/kali kali-rolling main contrib non-free non-free-firmware
# deb-src http://http.kali.org/kali kali-rolling main contrib non-free non-free-firmware

更新软件包

┌──(smoke㉿smoke-gs70-2pc-stealth)-[/etc/modprobe.d]
└─$ sudo apt update && sudo apt upgrade -y

2、检查显卡
查看显卡信息和驱动信息

┌──(smoke㉿smoke-gs70-2pc-stealth)-[/etc/modprobe.d]
└─$ lspci| grep -i vga
00:02.0 VGA compatible controller: Intel Corporation 4th Gen Core Processor Integrated Graphics Controller (rev 06)

┌──(smoke㉿smoke-gs70-2pc-stealth)-[/etc/modprobe.d]
└─$ lspci -s 00:02.0 -v
00:02.0 VGA compatible controller: Intel Corporation 4th Gen Core Processor Integrated Graphics Controller (rev 06) (prog-if 00 [VGA controller])
        DeviceName:  Onboard IGD
        Subsystem: Micro-Star International Co., Ltd. [MSI] Device 1104
        Flags: bus master, fast devsel, latency 0, IRQ 41, IOMMU group 0
        Memory at f6400000 (64-bit, non-prefetchable) [size=4M]
        Memory at d0000000 (64-bit, prefetchable) [size=256M]
        I/O ports at f000 [size=64]
        Expansion ROM at 000c0000 [virtual] [disabled] [size=128K]
        Capabilities: <access denied>
        Kernel driver in use: i915
        Kernel modules: i915

对于笔记办电脑或者迷你主机等有集成显卡的设备。主显示卡或许使用的是集成显卡,那么在lspci | grep -i vga这一步就不会显示nvidia独显。下面命令可以查看主显示卡是哪一个。

┌──(smoke㉿smoke-gs70-2pc-stealth)-[/etc/modprobe.d]
└─$ lspci| grep -i vga
00:02.0 VGA compatible controller: Intel Corporation 4th Gen Core Processor Integrated Graphics Controller (rev 06)

为了查看nvidia显卡,可以安全nvidia-detect,并运行此软件。

┌──(smoke㉿smoke-gs70-2pc-stealth)-[/etc/modprobe.d]
└─$ sudo apt install nvidia-detect  

┌──(smoke㉿smoke-gs70-2pc-stealth)-[/etc/modprobe.d]
└─$ nvidia-detect
Detected NVIDIA GPUs:
01:00.0 3D controller [0302]: NVIDIA Corporation GK104M [GeForce GTX 860M] [10de:119a] (rev a1)

Checking card:  NVIDIA Corporation GK104M [GeForce GTX 860M] (rev a1)
Uh oh. Failed to identify your Debian suite.

3、安装
上一步检查出来的信息中,kernel driver in use和kernel modules显示的是nouveau。说明现在使用的是开源通用驱动,而我们现在要安装nvidia闭源驱动和CUDA套件。

┌──(smoke㉿smoke-gs70-2pc-stealth)-[/etc/modprobe.d]
└─$ sudo apt install nvidia-driver nvidia-cuda-toolkit

如果原来驱动没有卸载,安装过程会提示以下信息

重启电脑

┌──(smoke㉿smoke-gs70-2pc-stealth)-[~]
└─$ sudo shutdown -r now

4、确认
检查nvidia驱动和CUDA套件是否安装成功。

┌──(smoke㉿smoke-gs70-2pc-stealth)-[~]
└─$ nvidia-smi

 

┌──(smoke㉿smoke-gs70-2pc-stealth)-[~]
└─$ lspci -s 00:02.0 -v
00:02.0 VGA compatible controller: Intel Corporation 4th Gen Core Processor Integrated Graphics Controller (rev 06) (prog-if 00 [VGA controller])
        DeviceName:  Onboard IGD
        Subsystem: Micro-Star International Co., Ltd. [MSI] Device 1104
        Flags: bus master, fast devsel, latency 0, IRQ 40, IOMMU group 0
        Memory at f6400000 (64-bit, non-prefetchable) [size=4M]
        Memory at d0000000 (64-bit, prefetchable) [size=256M]
        I/O ports at f000 [size=64]
        Expansion ROM at 000c0000 [virtual] [disabled] [size=128K]
        Capabilities: <access denied>
        Kernel driver in use: i915
        Kernel modules: i915

 查看显卡详细信息,例如温度、转速、内存占用等。

┌──(smoke㉿smoke-gs70-2pc-stealth)-[~]
└─$ nvidia-smi -i 0 -q