在18.04上安装nvidia驱动程序


31

所有。我正在尝试修复我的系统,以便可以安装nvidia驱动程序,但由于某种原因它似乎卡住了。我尝试手动从中删除下载的文件

/var/cache/apt/archives/libnvidia-gl-390_390.48-0ubuntu3_i386.deb
/var/cache/apt/archives/libnvidia-gl-390_390.48-0ubuntu3_amd64.deb

...以便让他们再次下载但无济于事。最近有人尝试在18.04上安装这些驱动程序吗?

~$ sudo apt --fix-broken install
[sudo] password for jarl: 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Correcting dependencies... Done
The following packages were automatically installed and are no longer required:
  lib32gcc1 libc6-i386
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
  libnvidia-gl-390 libnvidia-gl-390:i386
The following NEW packages will be installed
  libnvidia-gl-390 libnvidia-gl-390:i386
0 to upgrade, 2 to newly install, 0 to remove and 4 not to upgrade.
3 not fully installed or removed.
Need to get 0 B/29,1 MB of archives.
After this operation, 147 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
(Reading database ... 214344 files and directories currently installed.)
Preparing to unpack .../libnvidia-gl-390_390.48-0ubuntu3_i386.deb ...
diversion of /usr/lib/i386-linux-gnu/libGL.so.1 to /usr/lib/i386-linux-gnu/libGL.so.1.distrib by nvidia-340
dpkg-divert: error: mismatch on package
  when removing 'diversion of /usr/lib/i386-linux-gnu/libGL.so.1 by libnvidia-gl-390'
  found 'diversion of /usr/lib/i386-linux-gnu/libGL.so.1 to /usr/lib/i386-linux-gnu/libGL.so.1.distrib by nvidia-340'
dpkg: error processing archive /var/cache/apt/archives/libnvidia-gl-390_390.48-0ubuntu3_i386.deb (--unpack):
 new libnvidia-gl-390:i386 package pre-installation script subprocess returned error exit status 2
Preparing to unpack .../libnvidia-gl-390_390.48-0ubuntu3_amd64.deb ...
diversion of /usr/lib/x86_64-linux-gnu/libGL.so.1 to /usr/lib/x86_64-linux-gnu/libGL.so.1.distrib by nvidia-340
dpkg-divert: error: mismatch on package
  when removing 'diversion of /usr/lib/x86_64-linux-gnu/libGL.so.1 by libnvidia-gl-390'
  found 'diversion of /usr/lib/x86_64-linux-gnu/libGL.so.1 to /usr/lib/x86_64-linux-gnu/libGL.so.1.distrib by nvidia-340'
dpkg: error processing archive /var/cache/apt/archives/libnvidia-gl-390_390.48-0ubuntu3_amd64.deb (--unpack):
 new libnvidia-gl-390:amd64 package pre-installation script subprocess returned error exit status 2
Errors were encountered while processing:
 /var/cache/apt/archives/libnvidia-gl-390_390.48-0ubuntu3_i386.deb
 /var/cache/apt/archives/libnvidia-gl-390_390.48-0ubuntu3_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

尝试使用清理整个缓存,sudo apt-get clean然后重试。
卡尔·里希特

之后,sudo apt-get clean同样的事情仍然发生了我
皮姆黑伊登

Answers:


75

在ubuntu论坛上找到了此命令,与我合作得很好:

跑:

LC_MESSAGES=C dpkg-divert --list '*nvidia-340*' | sed -nre 's/^diversion of (.*) to .*/\1/p' | xargs -rd'\n' -n1 -- sudo dpkg-divert --remove
sudo apt --fix-broken install

第一条命令将从中删除所有转移的软件包nvidia-340。如果您有其他nvidia版本“转移”,请进行更改;阅读错误代码以了解哪个版本正在转移。

来源:https: //ubuntuforums.org/showthread.php ? t = 2388026 & p = 13761809#post13761809对stutteringp0et2表示感谢:)


2
如果您不使用英语使用Ubuntu,则需要进行更改,您必须将数字更改为awk '{print $3}'其他名称,例如,我必须将其更改为awk '{print $2}'。或者,您可以将语言环境更改为英语(for FILE in $(LANG=en dpkg-divert --list | grep nvidia-340 | awk '{print $3}'); do dpkg-divert --remove $FILE; done)。
Petr R.

2
您已将我从痛苦中解救出来,我在这里做了一个帐户只是为了
投票

14

这是另一个论坛完整答案

答案的基本前提是:

  1. 您有旧的依赖项要删除
  2. 你想清理烂摊子
  3. 您要安装新的驱动程序

我假设您从340驱动程序中安装了cr * p-这是我的问题

  1. 删除旧的依赖

    LC_MESSAGES=C dpkg-divert --list '*nvidia-340*' | sed -nre 's/^diversion of (.*) to .*/\1/p' | xargs -rd'\n' -n1 -- sudo dpkg-divert --remove
  2. 干净的混乱-取决于您安装的混乱,如果无法立即使用,请找出来;)

    sudo dpkg --force-all -P nvidia-390 nvidia-compute-utils-390 nvidia-dkms-390 nvidia-prime nvidia-settings nvidia-opencl-icd-340 nvidia-opencl-icd-384 nvidia-kernel-source-390 nvidia-kernel-common-390 libnvidia-cfg1-390 libnvidia-common-390 libnvidia-compute-390 libnvidia-decode-390 libnvidia-encode-390  libnvidia-fbc1-390 libnvidia-ifr1-390
    sudo apt purge --autoremove '*nvidia*'
    sudo apt-get update
    sudo apt-get upgrade
    
  3. 安装新的推荐驱动程序

    ubuntu-drivers devices
    nvidia-settings
    

我的建议是:
不要仅使用此cr * ppy驱动程序中的设置来检查是否已安装:)


3
请不要dpkg --force-all无故提出建议!遇到错误而导致的中止是为了保护程序包管理系统的完整性,不应不加思索地加以抑制!-1
大卫·佛斯特

这可行。我必须评论:使用4k显示器时,我检测到该问题出现-然后出现启动问题。我如何检测到:重新插入旧显示器,即可轻松启动
Vic Nicethemer 18/12 / 24,14

我做了#1,然后sudo apt install -f又做了sudo apt upgrade。工作了。
ICE

为什么这个答案几乎与卢卡斯·塞拉芬(Lucas Serafim)的答案相同?
Pim Heijden

6

我通过消除nvidia-340的转移来解决了这个问题。希望我不需要使用nvidia-340。以下是一个示例:

dpkg-divert --package nvidia-340 --remove /usr/lib/i386-linux-gnu/libGL.so.1

有冲突时,您可以继续删除。


万分感谢!乍一看,它似乎无法正常工作,但如果我们继续尝试并删除它,最终它将解决。再次感谢。
加拉夫·甘地

非常感谢!在不知道可以修改nvidia-340垃圾邮件的dpkg-divert列表的情况下,我无法解决这个问题。你摇滚
Mikis

2

我将运行apt auto-clean,看看它是否是我认为的混乱的包装。

sudo apt auto-clean
sudo apt update
sudo apt upgrade
sudo apt install nvidia-driver-390 libvulkan1

编辑:回答您的其他问题,当我前一天安装​​18.04时390工作正常,但转到396有点“有趣”。这为我解决了。


非常感谢。就我所知。:(我想我可能会重新安装):〜$ sudo apt upgrade阅读软件包列表...完成构建依赖树阅读状态信息...完成您可能想运行'apt- -fix-broken install”以更正这些错误。以下软件包具有未满足的依赖性。libnvidia-ifr1-390:依赖:libnvidia-gl-390,但未安装libnvidia-ifr1-390:i386:依赖:libnvidia-gl-390:i386,但未安装nvidia-driver-390:依赖:libnvidia- gl-390(= 390.48-0ubuntu3),但尚未安装....
Jarl Arntzen

.... Recommends: libnvidia-gl-390:i386 (= 390.48-0ubuntu3) E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).
Jarl Arntzen '18

1

先运行这个

#for FILE in $(dpkg-divert --list | grep nvidia-340 | awk '{print $3}'); do dpkg-divert --remove $FILE; done

然后从ppa安装

sudo add-apt-repository ppa:graphics-drivers/ppa 
sudo apt update 
sudo apt install nvidia-390

这在Ubuntu 18.04 LTS上对我有用


nvidia-driver-390位于默认的Ubuntu 18.04存储库中,那么添加PPA的意义何在?
卡雷尔
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.