我有一台 Nvidia 1070 系统,上面运行着 Ubuntu 18.04、Nvidia 驱动程序 396.37、CUDA 9.0,然后是 TensorFlow 和 Keras。
运行后sudo apt update
,当我运行时sudo apt upgrade
,我得到以下信息:
$ sudo apt upgrade
Reading package lists... Done
Building dependency tree
Reading state information... Done
You might want to run 'apt --fix-broken install' to correct these.
The following packages have unmet dependencies.
libglx-mesa0 : Depends: libglapi-mesa (= 18.0.5-0ubuntu0~18.04.1) but 18.2.8-0ubuntu0~18.04.2 is installed
Breaks: libglx-mesa0:i386 (!= 18.0.5-0ubuntu0~18.04.1) but 18.2.8-0ubuntu0~18.04.2 is installed
libglx-mesa0:i386 : Breaks: libglx-mesa0 (!= 18.2.8-0ubuntu0~18.04.2) but 18.0.5-0ubuntu0~18.04.1 is installed
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).
当我尝试建议时,sudo apt --fix-broken install
我看到以下内容:
$ sudo apt --fix-broken installReading package lists... Done
Building dependency tree
Reading state information... Done
Correcting dependencies... Done
The following packages were automatically installed and are no longer required:
libllvm6.0 libllvm6.0:i386 x11proto-dri2-dev x11proto-gl-dev
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
libglx-mesa0
The following packages will be upgraded:
libglx-mesa0
1 to upgrade, 0 to newly install, 0 to remove and 256 not to upgrade.
155 not fully installed or removed.
Need to get 0 B/135 kB of archives.
After this operation, 9216 B of additional disk space will be used.
Do you want to continue? [Y/n] y
(Reading database ... 591832 files and directories currently installed.)
Preparing to unpack .../libglx-mesa0_18.2.8-0ubuntu0~18.04.2_amd64.deb ...
Unpacking libglx-mesa0:amd64 (18.2.8-0ubuntu0~18.04.2) over (18.0.5-0ubuntu0~18.04.1) ...
dpkg: error processing archive /var/cache/apt/archives/libglx-mesa0_18.2.8-0ubuntu0~18.04.2_amd64.deb (--unpack):
trying to overwrite '/usr/lib/x86_64-linux-gnu/libGLX_indirect.so.0', which is also in package nvidia-396 396.37-0ubuntu1
Errors were encountered while processing:
/var/cache/apt/archives/libglx-mesa0_18.2.8-0ubuntu0~18.04.2_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)
sudo apt-get -o Dpkg::Options::="--force-overwrite" install --fix-broken
但是,我真的不想搞砸我的设置(因为让 CUDA、TensorFlow、Keras 等兼容版本正常工作是一项挑战),所以我会重视这是否是一种安全的方法。
编辑:关注这个建议@Jos,我备份了/usr/lib/x86_64-linux-gnu/libGLX_indirect.so.0
,然后继续使用这个--force-overwrite
方法。之后,TensorFlow、Keras 等基础设施似乎都运行良好。
$ sudo apt-get -o Dpkg::Options::="--force-overwrite" install --fix-broken
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:
libllvm6.0 libllvm6.0:i386 x11proto-dri2-dev x11proto-gl-dev
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
libglx-mesa0
The following packages will be upgraded:
libglx-mesa0
1 to upgrade, 0 to newly install, 0 to remove and 256 not to upgrade.
155 not fully installed or removed.
Need to get 0 B/135 kB of archives.
After this operation, 9216 B of additional disk space will be used.
Do you want to continue? [Y/n] y
(Reading database ... 591832 files and directories currently installed.)
Preparing to unpack .../libglx-mesa0_18.2.8-0ubuntu0~18.04.2_amd64.deb ...
Unpacking libglx-mesa0:amd64 (18.2.8-0ubuntu0~18.04.2) over (18.0.5-0ubuntu0~18.04.1) ...
dpkg: warning: overriding problem because --force enabled:
dpkg: warning: trying to overwrite '/usr/lib/x86_64-linux-gnu/libGLX_indirect.so.0', which is also in package nvidia-396 396.37-0ubuntu1
答案1
总结
请注意,下面的解决方案使用--force-overwrite
,它会附带警告。
来自@Jos 评论:
sudo apt-get -o Dpkg::Options::="--force-overwrite" install --fix-broken
Ubuntu 上的 Nvidia 驱动程序、CUDA 和 libglx 打包冲突总是很混乱 -_-|||