debian12下安装英伟达显卡驱动和CUDA套件
检查仓库源 确保仓库包含contrib和non-free部分。Kali默认就有此部分。Debian可能需要自己手动添加,建议检查下为好。 检查是否包括contrib和non-free grep “contrib non-free” /etc/apt/sources.list 如果没有的话,需要手动添加。源文件在/etc/apt/sources.list apt edit-sources 或 vim /etc/apt/sources.list deb http://deb.debian.org/debian/ bookworm main non-free-firmware 改为 deb http://deb.debian.org/debian/ bookworm main non-free-firmware non-free contrib 更新软件包 apt update 检查显卡 #lspci | grep -i vga root@ecs-70211683:~# lspci 00:00.0 Host bridge: Intel Corporation 440FX - 82441FX PMC [Natoma] (rev 02) 00:01.0 ISA bridge: Intel Corporation 82371SB PIIX3 ISA [Natoma/Triton II] 00:01.1 IDE interface: Intel Corporation 82371SB PIIX3 IDE [Natoma/Triton II] 00:01.2 USB controller: Intel Corporation 82371SB PIIX3 USB [Natoma/Triton II] (rev 01) 00:01.3 Bridge: Intel Corporation 82371AB/EB/MB PIIX4 ACPI (rev 03) 00:02.0 VGA compatible controller: Cirrus Logic GD 5446 00:03.0 Ethernet controller: Red Hat, Inc. Virtio network device 00:04.0 SCSI storage controller: Red Hat, Inc. Virtio SCSI 00:05.0 Communication controller: Red Hat, Inc. Virtio console
00:06.0 3D controller: NVIDIA Corporation GV100GL [Tesla V100S PCIe 32GB] (rev a1) 00:07.0 Unclassified device [00ff]: Red Hat, Inc. Virtio memory balloon 00:08.0 System peripheral: Intel Corporation 6300ESB Watchdog Timer 安装NVIDIA显卡驱动 安装nvidia-detect程序包 apt install nvidia-detect 执行上面安装的nvidia-detect命令检测您的 Nvidia 卡型号和建议的 Nvidia 驱动 程序 root@ecs-70211683:~# nvidia-detect Detected NVIDIA GPUs: 00:06.0 3D controller [0302]: NVIDIA Corporation GV100GL [Tesla V100S PCIe 32GB] [10de:1df6] (rev a1) Checking card: NVIDIA Corporation GV100GL [Tesla V100S PCIe 32GB] (rev a1) Uh oh. Failed to identify your Debian suite. 按照上一步的建议安装推荐的驱动程序 apt install -y nvidia-driver nvidia-cuda-toolkit 安装过程中会提示以下信息 ─────────────────────────────────┤ Configuring xserver-xorg-video-nvidia ├─────────────────────────────────┐ │ │ │ Conflicting nouveau kernel module loaded │
│ │ │ The free nouveau kernel module is currently loaded and conflicts with the non-free nvidia kernel module. │ │ │ │ The easiest way to fix this is to reboot the machine once the installation has finished. │ │ │ │ │ │ ———————————————— 重启电脑 reboot 检查nvidia驱动和CUDA套件是否安装成功 root@ecs-70211683:~# nvidia-smi Thu Aug 4 23:29:36 2022 +—————————————————————————–+ | NVIDIA-SMI 470.129.06 Driver Version: 470.129.06 CUDA Version: 11.4 | |——————————-+———————-+———————-+ | GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC | | Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. | | | | MIG M. | |===============================+======================+======================| | 0 NVIDIA GeForce … Off | 00000000:09:00.0 On | N/A | | 0% 55C P0 33W / 190W | 396MiB / 6075MiB | 1% Default | | | | N/A | +——————————-+———————-+———————-+ +—————————————————————————–+ | Processes: |
| GPU GI CI PID Type Process name GPU Memory | | ID ID Usage | |=============================================================================| | 0 N/A N/A 1078 G /usr/lib/xorg/Xorg 191MiB | | 0 N/A N/A 1474 G xfwm4 2MiB | +—————————————————————————–+ 输入nvidia-smi,查看的是你的GPU最大支持的CUDA版本。 nvcc –version,此时查看的才是你安装的cuda版本 CUDA分为两种,驱动API和运行API,驱动API指的是显卡驱动支持的最高cuda版本,我们运行程序时用的是运 行API。nvidia-smi显示的是驱动所能支持的最大运行API版本,nvcc –version查看的是CUDA的运行API版 本。 linux查看gpu使用率 watch -n 2 nvidia-smi (推荐) nvidia-smi -l 2 nvidia-smi dmon apt install nvtop