文章目录
- nvidia drivers下载
- 删除原有nvidia驱动
- 安装nvidia驱动
- 如果报错Unable to find the kernel source tree for the currently running
- building kernel modules
- 解决方法
- 报错
- 成功安装!!!
nvidia drivers下载
https://www.nvidia.cn/geforce/drivers/#:~:text=NVIDIA%20GeF
参考如下视频下载匹配的显卡和安装:
NVIDIA显卡的Ubuntu驱动程序安装方法
删除原有nvidia驱动
如果是apt-get方法安装的驱动
sudo apt-get remove nvidia-*
如果这样卸载不干净则:
sudo apt autoremove -y nvidia* --purge
sudo rm /etc/apt/sources.list.d/cuda*
sudo apt-get autoremove && sudo apt-get autoclean
sudo rm -rf /usr/local/cuda*
如果是run方法安装的驱动
sudo sh NVIDIA-Linux-x86_64-550.120.run -uninstall
怎样干净的卸载以前装的nvidia驱动?
安装nvidia驱动
chmod +x NVIDIA-Linux-x86_64-550.120.run
sudo bash NVIDIA-Linux-x86_64-550.120.run
当没有报错,或者
如果报错Unable to find the kernel source tree for the currently running
Unable to find the kernel source tree for the currently running
kernel. Please make sure you have installed the kernel source files
for your kernel and that they are properly configured; on Red Hat
Linux systems, for example, be sure you have the ‘kernel-source’ or
‘kernel-devel’ RPM installed. If you know the correct kernel source
files are installed, you may specify the kernel source path with the
‘–kernel-source-path’ command line option.
building kernel modules
ERROR: An error occurred while performing the step: “Building kernel
modules”. See /var/log/nvidia-installer.log for details.
查看之后发现:
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.2.0-3ubuntu1) 12.2.0
You are using: cc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0
x
86_64-linux-gnu-gcc-12 (Ubuntu 12.2.0-3ubuntu1) 12.2.0, GNU ld (GNU Binutils for Ubuntu) 2.39does not match the compiler used here:cc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0Copyright (C) 2021 Free Software Foundation, Inc.This is free software; see the source for copying conditions. There is NOwarranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.It is recommended to set the CC environment variableto the compiler that was used to compile the kernel.To skip the test and silence this warning message, setthe IGNORE_CC_MISMATCH environment variable to "1".However, mixing compiler versions between the kerneland kernel modules can result in subtle bugs that aredifficult to diagnose.
解决方法
sudo apt-get install gcc-12 g+±12
安装gcc12
sudo apt-get install gcc-12 g++-12
切换系统中的GCC版本,后面的100是优先级
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-12 100
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-12 100
假如系统中的GCC和G++版本为11,则降低它们的优先级
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-11 90
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-11 90
将gcc g++都切换为12版本,命令如下:
sudo update-alternatives --config gcc
There are 2 choices for the alternative gcc (providing /usr/bin/gcc).Selection Path Priority Status
------------------------------------------------------------
* 0 /usr/bin/gcc-12 100 auto mode1 /usr/bin/gcc-11 90 manual mode2 /usr/bin/gcc-12 100 manual modePress <enter> to keep the current choice[*], or type selection number: 2
报错
WARNING: Unable to determine the path to install the libglvnd EGL vendor
library config files. Check that you have pkg-config and the
libglvnd development libraries installed, or specify a path with
–glvnd-egl-config-path.
不用官,Ok即可,参考如下
Ubuntu安装NVIDIA驱动