nvidia cuda on debian12

介绍

Debian 12是最新发布的Debian GNU/Linux发行版,代号为Bookworm。
人工智能程序通常需要大量的计算资源,尤其是GPU,来加速训练和推理过程。
为了让Debian 12系统能够正常渲染桌面,并充分利用Nvidia GPU的性能,我们需要安装合适的显卡驱动。

Debian 12这次发行包含了许多软件的更新,比较重要的是Linux 内核映像使用了6.1版本,GNOME桌面使用了43版本。
Linux内核6.1带来了一些新的特性和改进,例如:
支持Rust语言编写内核代码,提高内核的安全性和可靠性。
引入MG-LRU算法,优化内存回收和提高系统性能。
改进Btrfs文件系统的性能。

debain仓库安装

apt autoremove nvidia* --purge
/usr/bin/nvidia-uninstall
/usr/local/cuda-X.Y/bin/cuda-uninstall

apt install software-properties-common -y
add-apt-repository contrib non-free-firmware
add-apt-repository contrib non-free
apt update

apt install linux-headers-amd64 nvidia-detect -y
nvidia-detect
apt install -y nvidia-driver linux-image-amd64

nvidia仓库安装

apt install dirmngr ca-certificates software-properties-common apt-transport-https dkms curl sudo -y
curl -fSsL https://developer.download.nvidia.com/compute/cuda/repos/debian12/x86_64/3bf863cc.pub | sudo gpg --dearmor | sudo tee /usr/share/keyrings/nvidia-drivers.gpg > /dev/null 2>&1
echo 'deb [signed-by=/usr/share/keyrings/nvidia-drivers.gpg] https://developer.download.nvidia.com/compute/cuda/repos/debian12/x86_64/ /' | sudo tee /etc/apt/sources.list.d/nvidia-drivers.list
apt update
apt install -y nvidia-driver cuda nvidia-smi nvidia-settings
nvidia-smi