ubuntu 22.04 安装驱动可能遇到的坑

  1. 第一个坑 【gcc版本不匹配】

请确认你的gcc版本是不是12的,11是编译不通过的。

一般在最后编译时报错,在/var/log/nvidia-installer.log日志中可以看到以下字样

bash 复制代码
Warning: Compiler version check failed:

The major and minor number of the compiler used to
compile the kernel:

x86_64-linux-gnu-gcc-12 (Ubuntu 12.3.0-1ubuntu1~22.04) 12.3.0, GNU ld (GNU Binutils for Ubuntu) 2.38

does not match the compiler used here:

cc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0
Copyright (C) 2021 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.


It is recommended to set the CC environment variable
to the compiler that was used to compile the kernel.

To skip the test and silence this warning message, set
the IGNORE_CC_MISMATCH environment variable to "1".
However, mixing compiler versions between the kernel
and kernel modules can result in subtle bugs that are
difficult to diagnose.

*** Failed CC version check. ***
  1. 没有找不到 gcc 或者cc
bash 复制代码
cd /usr/bin/
ls -al | grep gcc

去到/usr/bin目录下查看是否有gcc文件,如果只有gcc-12,需要创建软链接。

bash 复制代码
sudo ln -s /usr/bin/gcc-12 /usr/bin/gcc
sudo ln -s /usr/bin/gcc /usr/bin/cc

3.没有cc文件,报错如下

bash 复制代码
 ERROR: The CC sanity check failed:

         The C compiler '/usr/bin/cc' does not appear to be able to
         create object files.  Please make sure you have
         your Linux distribution's libc development package
         installed and that '/usr/bin/cc' is a valid C compiler
         name.

先检查cc软链接是否存在,可以参考坑2。

再去看看/usr/lib/gcc/x86_64-linux-gnu/12/目录下是否有cc1文件.

相关推荐
AI周红伟10 小时前
周红伟:OpenClaw+ 微信+ QQ+云上OpenClaw(Clawdbot)快速接入企业微信指南
运维·服务器·网络
KKKlucifer10 小时前
基于 UEBA 的堡垒机异常运维行为检测与告警模型
运维
数通工程师10 小时前
搞定数通设备账号安全:登录审计、紧急踢线、故障排查与配置规范
运维·网络·网络协议·安全·网络安全
ManchiBB10 小时前
Ubuntu 部署OpenClaw教程
linux·运维·ubuntu
桌面运维家10 小时前
Linux网络负载均衡:Nginx实战优化Web性能
linux·网络·负载均衡
智能运维指南11 小时前
信创改造 “二次开发陷阱“:国产DevOps 平台选型的原生功能完整性评估要点
运维·devops
Zfox_11 小时前
【Docker#6】Docker 容器常用命令
linux·运维·服务器·docker·容器
程序员一点11 小时前
第19章:openEuler 中的容器支持(Docker 与 iSulad)
运维·docker·容器·openeuler
胶水代码11 小时前
软件开发之DevOps
运维·devops
智能运维指南11 小时前
信创背景下,国产 DevOps 选型的价值跃迁路径设计(2026)
运维·devops