当尝试安装或删除软件包时,我遇到与 cuda 有关的错误。
例如,安装 curl (我已经安装了):
sudo apt install curl
Reading package lists... Done
Building dependency tree
Reading state information... Done
curl is already the newest version (7.58.0-2ubuntu3.16).
You might want to run 'apt --fix-broken install' to correct these.
The following packages have unmet dependencies:
cuda-libraries-dev-10-2 : Depends: libcublas-dev (>= 10.2.2.89) but it is not going to be installed
cuda-samples-10-2 : Depends: libcublas-dev (>= 10.2.2.89) but it is not going to be installed
cuda-visual-tools-10-2 : Depends: libcublas-dev (>= 10.2.2.89) but it is not going to be installed
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).
当对尚未安装的包执行此操作时,它也会给出同样缺少的依赖项(libcublas-dev
)并导致安装失败。
有什么帮助吗?
编辑:尝试sudo apt --fix-broken install
给出类似的错误:
Reading package lists... Done
Building dependency tree
Reading state information... Done
Correcting dependencies... Done
The following additional packages will be installed:
libcublas-dev
The following NEW packages will be installed:
libcublas-dev
0 upgraded, 1 newly installed, 0 to remove and 613 not upgraded.
7 not fully installed or removed.
Need to get 0 B/42.3 MB of archives.
After this operation, 114 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 file:/var/cuda-repo-10-2-local-10.2.89-440.40 libcublas-dev 10.2.2.89-1 [42.3 MB]
dpkg: warning: files list file for package 'cuda-libraries-10-2' missing; assuming package has no files currently installed
(Reading database ... 466055 files and directories currently installed.)
Preparing to unpack .../libcublas-dev_10.2.2.89-1_amd64.deb ...
Unpacking libcublas-dev (10.2.2.89-1) ...
dpkg: error processing archive /var/cuda-repo-10-2-local-10.2.89-440.40/./libcublas-dev_10.2.2.89-1_amd64.deb (--unpack):
trying to overwrite '/usr/include/cublas_v2.h', which is also in package nvidia-cuda-dev:amd64 10.0.130-0lambda3
dpkg-deb: error: paste subprocess was killed by signal (Broken pipe)
Errors were encountered while processing:
/var/cuda-repo-10-2-local-10.2.89-440.40/./libcublas-dev_10.2.2.89-1_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)
答案1
从关键错误行开始:
dpkg: error processing archive /var/cuda-repo-10-2-local-10.2.89-440.40/./libcublas-dev_10.2.2.89-1_amd64.deb (--unpack):
trying to overwrite '/usr/include/cublas_v2.h', which is also in package nvidia-cuda-dev:amd64 10.0.130-0lambda3
让我们稍微分析一下:
dpkg: error processing PACKAGE A:
trying to overwrite FILE, which is also in PACKAGE B
PACKAGE A = libcublas-dev:amd64 10.2.2.89-1
PACKAGE B = nvidia-cuda-dev:amd64 10.0.130-0lambda3
FILE = /usr/include/cublas_v2.h
第一个问题:包 A 和包 B 试图提供相同的文件。这意味着包冲突。该冲突是导致错误的原因。
第二个问题:看看每个软件包的版本号...它们不匹配。它们可能应该匹配。
- 您——人类管理员——必须决定哪个版本适合您的系统。
查看apt cache policy
这两个包。如果包来自不同的消息来源,这可能很糟糕。
- 如果您有多个来源,您(人工管理员)必须决定哪个来源为您的系统提供适当的软件包。
要解决这个问题,你必须做出两个决定(如上所示)。然后你必须实施你的决定:
禁用或删除冲突或不需要的源。它们无论如何都帮不了你。
卸载有冲突或错误版本的软件包。
也可以使用--force-overwrite
apt 的 quick-and-dirty 标志,这样错误消息就会消失。但是,我不建议这样做……它实际上并没有解决混合源提供错误版本软件包的根本问题,这可能会在某一天彻底破坏 Cuda。