![nvidia 安装程序默认使用旧版本的 GCC](https://linux22.com/image/1200220/nvidia%20%E5%AE%89%E8%A3%85%E7%A8%8B%E5%BA%8F%E9%BB%98%E8%AE%A4%E4%BD%BF%E7%94%A8%E6%97%A7%E7%89%88%E6%9C%AC%E7%9A%84%20GCC.png)
我正在使用 Ubunut 22.04,我想安装 nvidia 驱动程序:sudo ./cuda_12.1.0_530.30.02_linux.run
,但我首先收到一个警告:
warning: the compiler differs from the one used to build the kernel
The kernel was built by: x86_64-linux-gnu-gcc-12 (Ubuntu 12.3.0-1ubuntu1~22.04) 12.3.0
You are using: cc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0
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
我已经关注此解决方案将版本更改为 12.3,当我从终端检查时,我得到了 gcc/g++ 版本 12.3。
最后我收到一个错误:cc: error: unrecognized command-line option '-ftrivial-auto-var-init=zero'
,你能告诉我如何解决这个问题吗?提前谢谢了。
答案1
明确定义 gcc 版本
CC="gcc-12" sudo ./cuda_12.1.0_530.30.02_linux.run
解决了这个问题。