GPU驱动安装
Debian 12相关介绍及Nvidia GPU驱动安装与CUDA验证
Debian 12概述
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文件系统的性能。
与其他版本对比说明
- Debian 11存在一些问题,其桌面外观不太美观,并且安装xrdp登录后无法正常使用,因此推荐使用Debian 12。
- Ubuntu 22安装后,在换到其他主机时会出现网卡不能识别的情况。
- 对于没有显卡的情况,X79/X99主机无法正常启动,BIOS会报错。
安装Nvidia GPU驱动
Debian 12系统
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>&1echo '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
Debian 11系统
apt install dirmngr ca-certificates software-properties-common apt-transport-https dkms curl sudo -ycurl -fSsL https://developer.download.nvidia.com/compute/cuda/repos/debian11/x86_64/3bf863cc.pub | sudo gpg --dearmor | sudo tee /usr/share/keyrings/nvidia-drivers.gpg > /dev/null 2>&1echo 'deb [signed-by=/usr/share/keyrings/nvidia-drivers.gpg] https://developer.download.nvidia.com/compute/cuda/repos/debian11/x86_64/ /' | sudo tee /etc/apt/sources.list.d/nvidia-drivers.listapt update
安装驱动(无Cuda)
apt install -y nvidia-driver nvidia-kernel-open-dkms nvidia-smi nvidia-settings nvidia-detect
安装驱动(有Cuda)
apt install -y nvidia-driver nvidia-kernel-open-dkms cuda nvidia-smi nvidia-settings nvidia-detect
编写CUDA验证程序
apt install -y nvidia-cuda-toolkit-gccnano helloworld.cu
在helloworld.cu
中输入以下内容:
#include <stdio.h>
__global__ void helloFromGPU (void) { printf("Hello World from GPU!\n");}
int main(void) { printf("Hello World from CPU!\n"); helloFromGPU <<<1, 10>>>(); cudaDeviceReset(); return 0;}
编译并运行程序:
nvcc helloworld.cu -o helloworld./helloworld