在 Ubuntu 20.04 中安装 Nvidia 显卡驱动程序

在 Ubuntu 20.04 中安装 Nvidia 显卡驱动程序

我运行以下命令

sudo apt install nvidia-driver-450

但是它抛出了以下错误

Reading package lists... Done
Building dependency tree       
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information msudo apt install nvidia-driver-450
sudo rebootay help to resolve the situation:

The following packages have unmet dependencies:
 nvidia-driver-450 : Depends: libnvidia-gl-450 (= 450.80.02-0ubuntu1) but 450.80.02-0ubuntu0.20.04.2 is to be installed
                     Depends: nvidia-dkms-450 (= 450.80.02-0ubuntu1)
                     Recommends: nvidia-settings but it is not going to be installed
                     Recommends: nvidia-prime (>= 0.8) but it is not installable
                     Recommends: libnvidia-compute-450:i386 (= 450.80.02-0ubuntu1)
                     Recommends: libnvidia-decode-450:i386 (= 450.80.02-0ubuntu1)
                     Recommends: libnvidia-encode-450:i386 (= 450.80.02-0ubuntu1)
                     Recommends: libnvidia-ifr1-450:i386 (= 450.80.02-0ubuntu1)
                     Recommends: libnvidia-fbc1-450:i386 (= 450.80.02-0ubuntu1)
                     Recommends: libnvidia-gl-450:i386 (= 450.80.02-0ubuntu1)
E: Unable to correct problems, you have held broken packages.

我也尝试安装 nvidia-prime,但它说没有安装候选项。我尝试了在 askubuntu 上找到的所有方法,但仍然无法解决问题。我遗漏了什么吗?

答案1

  1. 删除所有 nvidia 包。

    sudo apt update
    sudo apt-get remove '^nvidia'
    sudo apt autoremove
    
  2. 如果您添加了 Nvidia PPA,请/etc/apt/sources.list在 sources.list 中该行前面加上 来删除该 PPA,以将#其注释掉。运行sudo apt update以刷新可用软件列表。

  3. 重启sudo reboot

  4. 运行以下命令安装 Nvidia 450 驱动程序。

    sudo apt install nvidia-driver-450
    sudo reboot
    

在 Ubuntu 20.04 中安装 nvidia-driver-450 显卡驱动程序后,它可以通过正常软件更新活动从 nvidia-driver-450 更新为 nvidia-driver-460。

作为步骤 4 的替代方法,您可以让ubuntu-drivers程序自动选择与您的 GPU 最兼容的专有 Nvidia 软件包,而不是猜测要安装哪些 Nvidia 驱动程序软件包。此方法尤其适用于 2022 年及以后,因为 nvidia-driver-450 目前是 Ubuntu 20.04 中 nvidia-driver-460 的过渡软件包。要以这种方式安装 Nvidia 专有驱动程序,请运行以下命令,而不是步骤 4 中的命令。

sudo ubuntu-drivers install && sudo reboot

这些步骤仍然适用于 nvidia-driver-470。

答案2

我遇到了类似的问题;

Reading package lists... Done
Building dependency tree       
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 nvidia-driver-450 : Depends: libnvidia-compute-450 (= 450.80.02-0ubuntu0.20.04.2) but 450.80.02-0ubuntu1 is to be installed
                     Depends: libnvidia-decode-450 (= 450.80.02-0ubuntu0.20.04.2) but it is not going to be installed
                     Depends: libnvidia-encode-450 (= 450.80.02-0ubuntu0.20.04.2) but it is not going to be installed
                     Recommends: nvidia-settings but it is not going to be installed
                     Recommends: nvidia-prime (>= 0.8) but it is not going to be installed
                     Recommends: libnvidia-compute-450:i386 (= 450.80.02-0ubuntu0.20.04.2)
                     Recommends: libnvidia-decode-450:i386 (= 450.80.02-0ubuntu0.20.04.2)
                     Recommends: libnvidia-encode-450:i386 (= 450.80.02-0ubuntu0.20.04.2)
                     Recommends: libnvidia-ifr1-450:i386 (= 450.80.02-0ubuntu0.20.04.2)
                     Recommends: libnvidia-fbc1-450:i386 (= 450.80.02-0ubuntu0.20.04.2)
E: Unable to correct problems, you have held broken packages.

我已经通过以下命令删除并清除了所有 nvidia* 包;

sudo apt-get remove nvidia*
sudo apt-get purge nvidia*
sudo apt-get autoremove
sudo apt-get autoclean

我通过以下方式解决了该问题;

sudo apt-get remove libnvidia*
sudo apt-get purge libnvidia*

相关内容