Skip to content

显卡驱动安装

对于桌面环境来说显卡驱动是非常重要的一个环节。其中 intel(核显)和 AMD 比较简单因为他们的驱动都是开源的,理论上在安装操作系统的时候会自动帮助我们安装好。这里所说的显卡驱动安装通常也只 Nvidia 显卡驱动安装。

Nvidia 显卡社区现状

由于 Nvidia 不提供开源的显卡驱动,社区就自己逆向发布了开源驱动Nouveau,他提供了 2D 的支持,3D 则由 CPU 来实现加速。 因此通常还需要安装Mesa这个开源的 3D 计算机图形库,他提供了通用的 OpenGL 实现。

Debian12 下安装 Nvidia 闭源驱动

对于新的显卡无脑安装就可以,如果是老显卡可能还需要开启 Unstable "Sid" 或者手动编译 才可以,更多的可以参考Debian wiki: Nvidia显卡安装

识别显卡

可以使用 lspci 来识别已经安装的 PCI 显卡的型号:

Bash
yangguodong@debian:~$ lspci -nn | egrep -i "3d|display|vga"
01:00.0 VGA compatible controller [0300]: NVIDIA Corporation GA104 [GeForce RTX 3070 Ti] [10de:2482] (rev a1)

也可以查看下目前显卡使用的驱动:

Bash
yangguodong@debian:~$ lspci -k
01:00.0 VGA compatible controller: NVIDIA Corporation GA104 [GeForce RTX 3070 Ti] (rev a1)
    Subsystem: Shenzhen Colorful Yugong Technology and Development Co. GA104 [GeForce RTX 3070 Ti]
    Kernel driver in use: nouveau
    Kernel modules: nouveau

默认安装使用的就是开源的 nouveau 驱动

nvidia-detect

Nvidia 官方提供了一个 nvidia-detect 脚本可以识别 GPU 和建议安装的驱动版本:

Bash
yangguodong@debian:~$ nvidia-detect
Detected NVIDIA GPUs:
01:00.0 VGA compatible controller [0300]: NVIDIA Corporation GA104 [GeForce RTX 3070 Ti] [10de:2482] (rev a1)

Checking card:  NVIDIA Corporation GA104 [GeForce RTX 3070 Ti] (rev a1)
Your card is supported by all driver versions.
Your card is also supported by the Tesla 470 drivers series.
It is recommended to install the
    nvidia-driver
package.

在 Debian 中该脚本位于 non-free 中,这个需要手动开启

显卡安装

Debian12 官方源只编译了 Version 535 驱动,可以从Nvidia 官方查看支持的设备。这里假设支持。

  1. 安装内核头文件以便 Nvidia 驱动程序构建
Bash
apt install linux-headers-amd64
  1. 添加 contrib non-free non-free-firmware 源到/etc/apt/sources.list
Bash
# Debian12

deb http://deb.debian.org/debian/ bookworm main contrib non-free non-free-firmware
  1. 更新软件源后安装 nvidia-driver 软件包以及 firmware-misc-nonfree 来在内核中构建 nvidia 模块
Bash
apt update
apt install nvidia-driver firmware-misc-nonfree
  1. 重启操作系统以加载新的驱动程序
Bash
yangguodong@debian:~$ lspci -k
01:00.0 VGA compatible controller: NVIDIA Corporation GA104 [GeForce RTX 3070 Ti] (rev a1)
    Subsystem: Shenzhen Colorful Yugong Technology and Development Co. GA104 [GeForce RTX 3070 Ti]
    Kernel driver in use: nvidia
    Kernel modules: nvidia