在 Ubuntu 18.04 上,我在安装 CUDA 时遇到了一些问题,所以我想卸载 CUDA 并从头开始。
因此,我尝试了以下方法:
sudo apt remove cuda
但随后打印出以下内容:
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.
cuda-libraries-dev-10-1 : Depends: libcublas-dev (>= 10.2.1.243) but it is not going to be installed
cuda-samples-10-1 : Depends: libcublas-dev (>= 10.2.1.243) but it is not going to be installed
cuda-visual-tools-10-1 : Depends: libcublas-dev (>= 10.2.1.243) but it is not going to be installed
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).
我对此感到很困惑。它似乎告诉我cuda-libraries-dev-10-1
,、cuda-samples-10-1
和cuda-visual-tools-10-1
都依赖于libcublas-dev
,并且至少是版本 10.2.1.243。然后它说libcublas-dev
不会安装这个版本的。但我试图卸载CUDA,不安装它。因此,当我试图删除这些软件包时,为什么我的系统要关心 CUDA 附带的一些软件包有未满足的依赖关系?
我可以理解,如果我尝试安装cuda-libraries-dev-10-1
、cuda-samples-10-1
或cuda-visual-tools-10-1
,那么此消息是有意义的。但如果我尝试删除这些,谁会在乎它们是否有未满足的依赖关系?
更新
根据建议,我还运行了:
apt --fix-broken install
然后打印出:
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:
g++-6 libaccinj64-9.1 libcublas9.1 libcudart9.1 libcufft9.1 libcufftw9.1 libcuinj64-9.1 libcurand9.1 libcusolver9.1 libcusparse9.1 libnppc9.1 libnppial9.1 libnppicc9.1
libnppicom9.1 libnppidei9.1 libnppif9.1 libnppig9.1 libnppim9.1 libnppist9.1 libnppisu9.1 libnppitc9.1 libnpps9.1 libnvblas9.1 libnvgraph9.1 libnvrtc9.1 libnvtoolsext1 libnvvm3
libstdc++-6-dev libthrust-dev libvdpau-dev nvidia-cuda-dev nvidia-cuda-doc nvidia-cuda-gdb nvidia-opencl-dev nvidia-profiler nvidia-visual-profiler ocl-icd-opencl-dev
opencl-c-headers
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
libcublas-dev
The following NEW packages will be installed
libcublas-dev
0 to upgrade, 1 to newly install, 0 to remove and 62 not to upgrade.
83 not fully installed or removed.
Need to get 0 B/38.9 MB of archives.
After this operation, 109 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 file:/var/cuda-repo-10-1-local-10.1.243-418.87.00 libcublas-dev 10.2.1.243-1 [38.9 MB]
(Reading database ... 211122 files and directories currently installed.)
Preparing to unpack .../libcublas-dev_10.2.1.243-1_amd64.deb ...
Unpacking libcublas-dev (10.2.1.243-1) ...
dpkg: error processing archive /var/cuda-repo-10-1-local-10.1.243-418.87.00/./libcublas-dev_10.2.1.243-1_amd64.deb (--unpack):
trying to overwrite '/usr/lib/x86_64-linux-gnu/libcublas_static.a', which is also in package nvidia-cuda-dev 9.1.85-3ubuntu1
dpkg-deb: error: paste subprocess was killed by signal (Broken pipe)
Errors were encountered while processing:
/var/cuda-repo-10-1-local-10.1.243-418.87.00/./libcublas-dev_10.2.1.243-1_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)
更新
根据评论中的建议,我随后尝试运行:
sudo apt full-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.
cuda-libraries-dev-10-1 : Depends: libcublas-dev (>= 10.2.1.243) but it is not installed
cuda-samples-10-1 : Depends: libcublas-dev (>= 10.2.1.243) but it is not installed
cuda-visual-tools-10-1 : Depends: libcublas-dev (>= 10.2.1.243) but it is not installed
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).
这和我运行时的打印输出完全相同sudo apt remove cuda
。
更新
根据评论中的建议,我运行了grep -r deb /etc/apt/sources.list /etc/apt/sources.list.d
。这给出了以下输出:
/etc/apt/sources.list:#deb cdrom:[Ubuntu 18.04.3 LTS _Bionic Beaver_ - Release amd64 (20190805)]/ bionic main restricted
/etc/apt/sources.list:deb http://gb.archive.ubuntu.com/ubuntu/ bionic main restricted
/etc/apt/sources.list:# deb-src http://gb.archive.ubuntu.com/ubuntu/ bionic main restricted
/etc/apt/sources.list:deb http://gb.archive.ubuntu.com/ubuntu/ bionic-updates main restricted
/etc/apt/sources.list:# deb-src http://gb.archive.ubuntu.com/ubuntu/ bionic-updates main restricted
/etc/apt/sources.list:deb http://gb.archive.ubuntu.com/ubuntu/ bionic universe
/etc/apt/sources.list:# deb-src http://gb.archive.ubuntu.com/ubuntu/ bionic universe
/etc/apt/sources.list:deb http://gb.archive.ubuntu.com/ubuntu/ bionic-updates universe
/etc/apt/sources.list:# deb-src http://gb.archive.ubuntu.com/ubuntu/ bionic-updates universe
/etc/apt/sources.list:deb http://gb.archive.ubuntu.com/ubuntu/ bionic multiverse
/etc/apt/sources.list:# deb-src http://gb.archive.ubuntu.com/ubuntu/ bionic multiverse
/etc/apt/sources.list:deb http://gb.archive.ubuntu.com/ubuntu/ bionic-updates multiverse
/etc/apt/sources.list:# deb-src http://gb.archive.ubuntu.com/ubuntu/ bionic-updates multiverse
/etc/apt/sources.list:deb http://gb.archive.ubuntu.com/ubuntu/ bionic-backports main restricted universe multiverse
/etc/apt/sources.list:# deb-src http://gb.archive.ubuntu.com/ubuntu/ bionic-backports main restricted universe multiverse
/etc/apt/sources.list:# deb http://archive.canonical.com/ubuntu bionic partner
/etc/apt/sources.list:# deb-src http://archive.canonical.com/ubuntu bionic partner
/etc/apt/sources.list:deb http://security.ubuntu.com/ubuntu bionic-security main restricted
/etc/apt/sources.list:# deb-src http://security.ubuntu.com/ubuntu bionic-security main restricted
/etc/apt/sources.list:deb http://security.ubuntu.com/ubuntu bionic-security universe
/etc/apt/sources.list:# deb-src http://security.ubuntu.com/ubuntu bionic-security universe
/etc/apt/sources.list:deb http://security.ubuntu.com/ubuntu bionic-security multiverse
/etc/apt/sources.list:# deb-src http://security.ubuntu.com/ubuntu bionic-security multiverse
/etc/apt/sources.list.d/cuda.list:deb http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64 /
/etc/apt/sources.list.d/cuda-10-0-local-10.0.130-410.48.list:deb file:///var/cuda-repo-10-0-local-10.0.130-410.48 /
/etc/apt/sources.list.d/cuda-10-1-local-10.1.243-418.87.00.list:deb file:///var/cuda-repo-10-1-local-10.1.243-418.87.00 /
答案1
我遇到了同样的问题。这拯救了我(替换为您的软件包版本):
sudo dpkg -i --force-overwrite /var/cache/apt/archives/libcublas-dev_10.2.1.243-1_amd64.deb
进而:
sudo apt --fix-broken install
答案2
dpkg: 处理存档 /var/cuda-repo-10-1-local-10.1.243-418.87.00/./libcublas-dev_10.2.1.243-1_amd64.deb (--unpack) 时出错:试图覆盖‘/usr/lib/x86_64-linux-gnu/libcublas_static.a’,该存档也在包 nvidia-cuda-dev 9.1.85-3ubuntu1 中 dpkg-deb:错误:粘贴子进程被信号终止(管道断裂)
2 个具有相同文件的包
sudo mv usr/lib/x86_64-linux-gnu/libcublas_static.a usr/lib/x86_64-linux-gnu/libcublas_static.a.bak
然后
sudo dpkg --configure -a
如果此操作有效,请尝试再次清除 cuda
答案3
Unpacking libcublas-dev (10.2.1.243-1) ... dpkg: error processing archive /var/cuda-repo-10-1-local-10.1.243-418.87.00/./libcublas-dev_10.2.1.243-1_amd64.deb (--unpack): trying to overwrite '/usr/lib/x86_64-linux-gnu/libcublas_static.a', which is also in package nvidia-cuda-dev 9.1.85-3ubuntu1
让我们稍微解释一下这个错误:你有两个包不相容因为每个都试图提供相同的文件。这两个包分别是libcublas-dev
(来自 CUDA)和nvidia-cuda-dev
(来自 Ubuntu)。
他们都尝试提供的文件是/usr/lib/x86_64-linux-gnu/libcublas_static.a
您有多种选择。
您可以放弃 CUDA,卸载 CUDA 包,并删除 CUDA 存储库。
您可以卸载 NVIDIA 软件包。请勿删除 Ubuntu 存储库。
您可以使用 dpkg 的
--force-overwrite
标志使两个原本不兼容的软件包一起工作。这样您就不需要卸载或删除任何东西了。sudo apt install --force-overwrite libcublas-dev
使用
--force
时应小心谨慎。它可能会导致将来升级、删除或其他软件包操作出现问题。请务必在您自己的笔记中记录您需要--force-overwrite
同时安装 CUDA 和 NVIDIA 软件包所需的内容。
答案4
在 CUDA 文档中删除 CUDA 工具包 10.1 和驱动程序据记录,您需要使用以下命令:
$ sudo apt-get --purge remove "*cublas*" "cuda*"
当你使用sudo apt-get --purge remove cuda
元包时,系统将开始尝试解析包。它在我安装在 Ubuntu 20.04 上时起作用了