我正在使用 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
解决了这个问题。