Debian 如何 NVIDIA 显卡

From 清冽之泉
Jump to navigation Jump to search

Nouveau

The nouveau project aims to build high-quality, free/libre software drivers for nVidia cards.

旧头文件:

linux-headers-5.10.0-18-amd64
linux-headers-5.10.0-18-common
linux-image-5.10.0-18-amd64
linux-image-amd64

nvidia-detect结果:

Detected NVIDIA GPUs:
01:00.0 3D controller [0302]: NVIDIA Corporation GM107M [GeForce GTX 950M] [10de:139a] (rev a2)

Checking card:  NVIDIA Corporation GM107M [GeForce GTX 950M] (rev a2)
Your card is supported by all driver versions.
Your card is also supported by the Tesla drivers series.
Your card is also supported by the Tesla 470 drivers series.
It is recommended to install the
    nvidia-driver
package.

debian.org

lspci -nn | egrep -i "3d|display|vga"
nvidia-detect 结果是 nvidia-driver。nvidia 提供的 bookworm 优化版是 Version 525.105.17,支持 GTX 9950m
sudo apt install linux-headers-amd64 要安装正确的 headers,最新版是 6.1.55-1
sudo apt install nvidia-kernel-dkms 525.125.06-1~deb12u1
sudo apt install nvidia-driver firmware-misc-nonfree
sudo nvidia-settings 设置显卡
关注 secureboot
 Debian 不需要禁 nouveau
sudo apt install nvidia-cuda-dev nvidia-cuda-toolkit 不知道它们是否是必要的
sudo apt install libnvoptix1 安装 OptiX 引擎
如果安装失败就这样复原,成功率很高
sudo apt purge "*nvidia*"
sudo systemctl reboot
sudo apt install --reinstall xserver-xorg-core xserver-xorg-video-nouveau
sudo X -configure

nvidia.com

NVIDIA-Linux-x86_64-525.105.17.run 已下载好,395.39 MB。

lsmod | grep nouveau 有输出则表示 nouveau 正在运行
$ cat <<EOF | sudo tee /etc/modprobe.d/blacklist-nouveau.conf
 blacklist nouveau
 options nouveau modeset=0
 EOF
$ sudo update-initramfs -u
sudo systemctl reboot
lsmod | grep nouveau 无输出则表示禁成功
lspci | grep -i nvidia 检测是否具备 CUDA 能力,有输出且包含在官方支持页面,则支持
uname -r 查看正在 running  kernel 6.1.0-12-amd64

旧时代避灾

sudo apt install nvidia-xconfig
sudo nvidia-xconfig
sudo mkdir -p /etc/X11/xorg.conf.d
sudo echo -e 'Section "Device"\n\tIdentifier "My GPU"\n\tDriver "nvidia"\nEndSection' > /etc/X11/xorg.conf.d/20-nvidia.conf
上两步等价于 emacs /etc/X11/xorg.conf.d/20-nvidia.conf
<pre>
Section "Device"
        Identifier "My GPU"
        Driver "nvidia"
EndSection
</pre>

Restart your system at this point to enable the nouveau driver blacklist.

野教程

sudo apt install nvidia-smi
nvidia-smi 查看驱动版本,也等于查看是否安装成功
sudo modinfo -F filename nouveau 查看相关模块,我的输出:/lib/modules/6.1.0-12-amd64/kernel/drivers/gpu/drm/nouveau/nouveau.ko
sudo emacs /etc/modprobe.d/blacklist-nouveau.conf 插入
 blacklist nouveau
 options nouveau modeset=0
sudo update-initramfs -u
lsmod | grep nouveau 无信息则表示禁用成功
  • GPU 显卡
  • GPU Driver 显卡驱动 for nvidia
  • CUDA Driver 显卡驱动 for nvidia 当并行计算强烈时这种 Driver 发挥作bvq
  • CUDA 一种架构
  • CUDA Toolkit 工具包,编译链
  • NVCC 编译器 for CUDA
  • CUDNN 深度学习加速库 for CUDA

CUDA Driver 一定要满足 CUDA Toolkit 的最低版本要求。

sudo apt remove --purge nvidia* sudo sh ./nvida.run --uninstall 卸载已安装的驱动
 bios 中禁用 secure boot
 /etc/modprobe.d/blacklist.conf 中禁用驱动
 blacklist nouveau
 options nouveau modeset=0
sudo update-initramfs -u
sudo systemctl reboot
lsmod | grep nouveau 没输出则代表禁成功了
systemctl set-default multi-user.target 关图形界面,再安装驱动
systemctl reboot
bash NVIDIA-Linux-x86_64-390.116.run
systemctl set-default graphical.target 开图形界面
systemctl reboot 成功安装驱动

卸载

cd /usr/local/cuda/bin
sudo ./uninstall_cuda_10.0.pl
sudo rm-rf cuda-10.0