RTX4060安装nvidia显卡驱动

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.39
   
   does not match the compiler used here:
   
   cc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0
   Copyright (C) 2021 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.
   
   
   It is recommended to set the CC environment variable
   to the compiler that was used to compile the kernel.
   
   To skip the test and silence this warning message, set
   the IGNORE_CC_MISMATCH environment variable to "1".
   However, mixing compiler versions between the kernel
   and kernel modules can result in subtle bugs that are
   difficult 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 mode
  1            /usr/bin/gcc-11   90        manual mode
  2            /usr/bin/gcc-12   100       manual mode

Press <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驱动

成功安装!!!

在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

computer_vision_chen

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值