Ubuntu 22.04安装显卡驱动时遇到无法安装情况
RROR (dkms apport): kernel package linux-headers-6.2.2-060202-generic is not supported
Error! Bad return status for module build on kernel: 6.2.2-060202-generic (x86_64)
Consult /var/lib/dkms/nvidia/525.89.02/build/make.log for more information.
dpkg: error processing package nvidia-dkms-525 (--configure):
installed nvidia-dkms-525 package post-installation script subprocess returned error exit status 10
dpkg: dependency problems prevent configuration of nvidia-driver-525:
nvidia-driver-525 depends on nvidia-dkms-525 (<= 525.89.02-1); however:
Package nvidia-dkms-525 is not configured yet.
nvidia-driver-525 depends on nvidia-dkms-525 (>= 525.89.02); however:
Package nvidia-dkms-525 is not configured yet.
dpkg: error processing package nvidia-driver-525 (--configure):
dependency problems - leaving unconfigured
No apport report written because the error message indicates it's a follow-up error from a previous failure.
P
rocessing triggers for initramfs-tools (0.140ubuntu13.1) ...
update-initramfs: Generating /boot/initrd.img-6.2.2-060202-generic
Errors were encountered while processing:
nvidia-dkms-525
nvidia-driver-525
E: Sub-process /usr/bin/dpkg returned an error code (1)
直接使用apt安装NVIDIA显卡驱动时遇到以上错误
网上直接搜说是因为内核问题,本人升级了内核也没有解决此问题
最后在日志中发现可能是本机编译时出错,则大概率是gcc以及g++版本的问题,最后通过升级gcc和g++的版本,然后重新安装解决此问题
最后记录gcc和g++的版本安装切换:
sudo apt install gcc-[version]
sudo apt install g++-[version]
安装切换选项, 40代表优先级,这个随便写问题不大,不要一样就行。
–slave保证gcc和g++版本统一,有的gcc和g++需要分开配置,则使用–slave会报错
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-[version] 40 --slave /usr/bin/g++ g++ /usr/bin/g++-[version]
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-[version] 40
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-[version] 40
卸载切换选项
sudo update-alternatives --remove gcc /usr/bin/gcc-[version]