安装Nvidia驱动出现 cc: error: unrecognized command-line option ‘-ftrivial-auto-var-init=zero’
ubuntu22.04
navidia-driver:NVIDIA-Linux-x86_64-550.
报错:cc: error: unrecognized command-line option ‘-ftrivial-auto-var-init=zero’
需要 gcc-12 才能正确编译
删除 nvidia 驱动程序:
sudo apt-get purge nvidia && sudo apt-get autoremove
1
更新 gcc 并更新替代方案:
sudo apt-get install gcc-12
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-12 12
检查 gcc 版本,现在应该显示 v :
gcc --version
gcc (Ubuntu 12.1.0-2ubuntu1~22.04) 12.1.0
Copyright © 2022 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.
重新安装nvidia驱动:
sudo sh ./NVIDIA-Linux-x86_64-550. --no-opengl-files --no-x-check --no-nouveau-check