惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Simon Willison's Weblog
Simon Willison's Weblog
Help Net Security
Help Net Security
P
Privacy International News Feed
T
Threat Research - Cisco Blogs
C
Cisco Blogs
C
CERT Recently Published Vulnerability Notes
NISL@THU
NISL@THU
L
LINUX DO - 热门话题
Security Latest
Security Latest
A
Arctic Wolf
G
GRAHAM CLULEY
月光博客
月光博客
S
Securelist
D
Docker
J
Java Code Geeks
T
Troy Hunt's Blog
T
Tenable Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
SecWiki News
SecWiki News
S
Security @ Cisco Blogs
量子位
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
L
LINUX DO - 最新话题
Recent Commits to openclaw:main
Recent Commits to openclaw:main
aimingoo的专栏
aimingoo的专栏
博客园 - 【当耐特】
H
Heimdal Security Blog
The Hacker News
The Hacker News
博客园 - 三生石上(FineUI控件)
Application and Cybersecurity Blog
Application and Cybersecurity Blog
N
Netflix TechBlog - Medium
Vercel News
Vercel News
Forbes - Security
Forbes - Security
B
Blog RSS Feed
H
Hackread – Cybersecurity News, Data Breaches, AI and More
IT之家
IT之家
B
Blog
MongoDB | Blog
MongoDB | Blog
博客园 - 聂微东
Google DeepMind News
Google DeepMind News
S
Secure Thoughts
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
C
Check Point Blog
云风的 BLOG
云风的 BLOG
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
T
The Blog of Author Tim Ferriss
L
Lohrmann on Cybersecurity
F
Full Disclosure
D
Darknet – Hacking Tools, Hacker News & Cyber Security
P
Proofpoint News Feed

钧言极客

Alpine Linux 服务器配置指北 Visual Studio Code 安装开启 中文语言包插件 Linux 安装 MediaInfo:轻松解析视频文件信息 Hugo 实现的短标签 PVE存储合并实践:整合local-lvm到local 组网工具WireGuard入门指南 Linux 管理 UFW 防火墙 Alpine VNC重置密码
Debian 安装NVIDLA显卡驱动和CUDA工具包
JunYan · 2026-01-02 · via 钧言极客

最近在尝试使用CUDA训练模型,在安装CUDA的过程中,需要安装英伟达显卡驱动,但是英伟达显卡驱动的安装非常麻烦,这里记录一下 NVIDLA 显卡驱动的安装过程。

确认硬件型号 和 软件源

禁用 Secure Boot

若主板启用了 Secure Boot,NVIDIA 闭源驱动的内核模块可能因未签名而无法加载。可在 BIOS/UEFI 中禁用 Secure Boot,或参考 Debian Secure Boot 文档 进行模块签名。

显卡型号

使用 lspci 命令查看 NVIDIA GPU 型号:

使用的显卡型号是 GeForce RTX 3060

lspci | grep -i nvidia

# 输出
01:00.0 VGA compatible controller: NVIDIA Corporation GA106 [GeForce RTX 3060] (rev a1)

若输出为空,可能是显卡未安装或者未正确安装(检查硬件连接)。

软件源

在更新源当中,sources.list 确保包含 mainnon-freenon-free-firmware

cat /etc/apt/sources.list
# 输出
deb https://mirrors.tuna.tsinghua.edu.cn/debian/ trixie main contrib non-free non-free-firmware

deb https://mirrors.tuna.tsinghua.edu.cn/debian/ trixie-updates main contrib non-free non-free-firmware

deb https://mirrors.tuna.tsinghua.edu.cn/debian/ trixie-backports main contrib non-free non-free-firmware

deb https://security.debian.org/debian-security trixie-security main contrib non-free non-free-firmware

安装内核和显卡驱动

这里我使用的是 Debian 13系统,apt包管理器自带的版本也会比较高,如果是5000系列显卡,则需要手动选择590系列驱动进行安装: 通过NVIDIA官方文件安装 。

仓库自带 NVIDIA 550版本驱动,支持GTX 700系列显卡至RTX 4000系列显卡,CUDA 12.4版本。

更新内核头文件

NVIDIA 驱动需编译内核模块,因此需安装与当前内核匹配的头文件。

uname -r
# 输出
6.1.0-13-amd64

# 安装内核头文件
sudo apt install linux-headers-amd64 dkms

# 快捷模式(二选一)
sudo apt update && sudo apt install linux-headers-$(uname -r) dkms

安装 NVIDLA 显卡驱动

使用 apt 安装

Debian 官方仓库(contrib 和 non-free 组件)提供测试过 NVIDIA 闭源驱动,兼容性最佳。

sudo apt install nvidia-driver firmware-misc-nonfree

安装成功后,重启系统。使用 nvidia-smi 命令查看显卡信息。

nvidia

显卡信息显示正常,则安装成功。

通过NVIDIA官方文件安装

NVIDIA 提供独立的 .run 的格式安装包,安装最新的驱动文件。除非是5000系列NVIDIA 显卡或者需要最新的驱动版本,否则使用官方源提供的安装包安装(稳)。

  1. 获取 NVIDIA 官方驱动文件

访问 NVIDIA 获取驱动下载 ,选择对应系统版本和显卡型号,下载 .run 格式的驱动文件。(如:NVIDIA-Linux-x86_64-580.119.02.run)

  1. 关闭图形界面(Wayland/Xorg)
  • Ctrl + Alt + F3 切换到 TTY3,登录账户
  • 关闭图形界面
# 查看当前显示管理器(Debian 默认 GDM3)
sudo systemctl status display-manager  # 输出如 "gdm3.service"
 
# 停止显示管理器(会退出图形界面,进入 TTY)
sudo systemctl stop gdm3  # 或 lightdm、sddm 等
  1. 安装 NVIDIA 显卡驱动
#  添加执行权限
chmod +x NVIDIA-Linux-x86_64-580.119.02.run
# 运行安装
sudo ./NVIDIA-Linux-x86_64-580.119.02.run
# 重启系统
sudo reboot

安装选项建议:

  • 是否保留 Nouveau? → No
  • 启用 3D 支持? → Yes
  • 自动更新 Xorg 配置? → Yes(除非有自定义配置)
  • 安装 32-bit 兼容库? → 按需选择(通常选 Yes
  1. 启动图形界面
# 重启显示管理器
sudo systemctl start gdm  # 或 lightdm、sddm 等

Ctrl + Alt + F1 返回图形界面

  1. 验证安装
nvidia-smi  # 出现 GPU 信息表即成功
sudo apt install nvidia-cuda-dev nvidia-cuda-toolkit

安装成功后,重启系统。使用 nvcc 命令查看 CUDA 版本。

nvcc --version
# 示例输出
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2024 NVIDIA Corporation
Cuda compilation tools, release 12.4, V12.4.131

说明cuda/nvcc可以正常工作了。