Ubuntu版本:18.04 Apt版本:1.6.13
我尝试安装不同的 cuda 工具包,但这样做可能会不可避免地破坏 apt。但我认为问题与 cuda 无关,问题出在 apt 身上。
如果我运行sudo apt-get install *anything*
(或 apt remove 或 apt purge),我会收到错误:
Reading package lists... Done Building dependency tree Reading state information... Done cuda is already the newest version (11.2.2-1). You might want to run 'apt --fix-broken install' to correct these. The following packages have unmet dependencies. cuda-drivers-460 : Depends: libnvidia-common-460 (>= 460.32.03) but it is not going to be installed libnvidia-gl-460 : Depends: libnvidia-common-460 but it is not going to be installed E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).
所以我尝试sudo apt --fix-broken install
:
Get:1 file:/var/cuda-repo-ubuntu1804-11-2-local libnvidia-common-460 460.32.03-0ubuntu1 [10.2 kB] Err:1 file:/var/cuda-repo-ubuntu1804-11-2-local libnvidia-common-460 460.32.03-0ubuntu1 File not found - /var/cuda-repo-ubuntu1804-11-2-local/./libnvidia-common-460_460.32.03-0ubuntu1_all.deb (2: No such file or directory) E: Failed to fetch file:/var/cuda-repo-ubuntu1804-11-2-local/./libnvidia-common-460_460.32.03-0ubuntu1_all.deb File not found - /var/cuda-repo-ubuntu1804-11-2-local/./libnvidia-common-460_460.32.03-0ubuntu1_all.deb (2: No such file or directory) E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?
确实/var/cuda-repo-ubuntu1804-11-2-local
不存在,更不用说其中的文件了。
运行sudo apt-get update
收益:
E: The repository 'file:/var/cuda-repo-10-1-local-10.1.105-418.39 Release' no longer has a Release file. N: Updating from such a repository can't be done securely, and is therefore disabled by default. N: See apt-secure(8) manpage for repository creation and user configuration details. E: The repository 'file:/var/cuda-repo-ubuntu1804-11-2-local Release' no longer has a Release file. N: Updating from such a repository can't be done securely, and is therefore disabled by default. N: See apt-secure(8) manpage for repository creation and user configuration details.
这可能又是由于没有/var/cuda-repo-ubuntu1804-11-2-local
(或/var/cuda-repo-10-1-local-10.1.105-418.39
)
遵循https://forums.linuxmint.com/viewtopic.php?t=281922
我也尝试过:
sudo su for FILE in $(dpkg-divert --list | grep nvidia-440 | awk '{print $3}'); do dpkg-divert --remove $FILE; done exit
但输入行开头for FILE...
没有任何作用(nvidia-440
用 450 或 460 替换也没有作用)
我正在使用 apt 版本 1.6.13,我尝试通过运行重新安装sudo dpkg -i apt_1.6.13_amd64.deb
(从http://archive.ubuntu.com/ubuntu/pool/main/a/apt/apt_1.6.13_amd64.deb
)但运行上述任何程序时我仍然会遇到同样的错误
任何建议都将不胜感激 - 我真的想避免重新安装 ubuntu。
答案1
这更像是对 @ubfan1 的回复,但问题是我无法重新启动/删除系统上任何残留的 cuda。答案在如何在 Ubuntu 中安装 NVIDIA 和 CUDA 驱动程序?
提供了魔力:sudo rm /etc/apt/sources.list.d/cuda*
然后允许我运行更新,然后修复损坏的安装
答案2
我发现这sudo rm /etc/apt/sources.list.d/cuda-ubuntu2004-11-7-local.list
已经解决了sudo apt update
噪音问题(同时没有像 w1nter 的回答中那样删除其他 cuda* 文件)。以下是抄录:
(torch) sharker@persephone:~$ sudo apt update
[sudo] password for sharker:
Get:1 file:/var/cuda-repo-ubuntu2004-11-7-local InRelease
Ign:1 file:/var/cuda-repo-ubuntu2004-11-7-local InRelease
Get:2 file:/var/cuda-repo-ubuntu2004-11-7-local Release
Err:2 file:/var/cuda-repo-ubuntu2004-11-7-local Release
File not found - /var/cuda-repo-ubuntu2004-11-7-local/Release (2: No such file or directory)
Hit:4 http://us.archive.ubuntu.com/ubuntu focal InRelease
Get:5 http://security.ubuntu.com/ubuntu focal-security InRelease [114 kB]
Get:6 http://us.archive.ubuntu.com/ubuntu focal-updates InRelease [114 kB]
Hit:7 http://dl.google.com/linux/chrome/deb stable InRelease
Ign:9 http://linux.dropbox.com/ubuntu disco InRelease
Hit:10 http://linux.dropbox.com/ubuntu disco Release
Hit:11 https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64 InRelease
Get:12 http://us.archive.ubuntu.com/ubuntu focal-backports InRelease [108 kB]
Hit:3 https://apt.llvm.org/focal llvm-toolchain-focal-12 InRelease
Hit:8 https://apt.llvm.org/focal llvm-toolchain-focal-14 InRelease
Get:14 http://security.ubuntu.com/ubuntu focal-security/main amd64 DEP-11 Metadata [40.7 kB]
Get:15 http://security.ubuntu.com/ubuntu focal-security/universe amd64 DEP-11 Metadata [66.7 kB]
Get:16 http://security.ubuntu.com/ubuntu focal-security/multiverse amd64 DEP-11 Metadata [2,464 B]
Get:17 http://us.archive.ubuntu.com/ubuntu focal-updates/main amd64 DEP-11 Metadata [278 kB]
Get:18 http://us.archive.ubuntu.com/ubuntu focal-updates/universe amd64 DEP-11 Metadata [391 kB]
Get:19 http://us.archive.ubuntu.com/ubuntu focal-updates/multiverse amd64 DEP-11 Metadata [940 B]
Get:20 http://us.archive.ubuntu.com/ubuntu focal-backports/main amd64 DEP-11 Metadata [8,024 B]
Get:21 http://us.archive.ubuntu.com/ubuntu focal-backports/universe amd64 DEP-11 Metadata [30.5 kB]
Reading package lists... Done
E: The repository 'file:/var/cuda-repo-ubuntu2004-11-7-local Release' no longer has a Release file.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.
在咨询了 w1nter 的回答后,我sudo apt update
使用以下命令删除了错误:
(torch) sharker@persephone:/var$ cd /etc/apt/sources.list.d
(torch) sharker@persephone:/etc/apt/sources.list.d$ ls
cuda-ubuntu2004-11-7-local.list dropbox.list google-chrome.list.save
cuda-ubuntu2004-x86_64.list dropbox.list.save
cuda-ubuntu2004-x86_64.list.save google-chrome.list
(torch) sharker@persephone:/etc/apt/sources.list.d$ ls -la
total 36
drwxr-xr-x 2 root root 4096 May 24 13:39 .
drwxr-xr-x 7 root root 4096 May 15 20:27 ..
-rw-r--r-- 1 root root 108 May 4 12:10 cuda-ubuntu2004-11-7-local.list
-rw-r--r-- 1 root root 139 May 15 20:27 cuda-ubuntu2004-x86_64.list
-rw-r--r-- 1 root root 139 May 15 20:27 cuda-ubuntu2004-x86_64.list.save
-rw-r--r-- 1 root root 65 May 15 20:27 dropbox.list
-rw-r--r-- 1 root root 65 May 15 20:27 dropbox.list.save
-rw-r--r-- 1 root root 189 May 15 20:27 google-chrome.list
-rw-r--r-- 1 root root 189 May 15 20:27 google-chrome.list.save
(torch) sharker@persephone:/etc/apt/sources.list.d$ sudo rm cuda-ubuntu2004-11-7-local.list
(torch) sharker@persephone:/etc/apt/sources.list.d$ sudo apt update
Hit:2 http://us.archive.ubuntu.com/ubuntu focal InRelease
Ign:3 http://linux.dropbox.com/ubuntu disco InRelease
Hit:4 http://us.archive.ubuntu.com/ubuntu focal-updates InRelease
Hit:5 http://dl.google.com/linux/chrome/deb stable InRelease
Hit:7 http://linux.dropbox.com/ubuntu disco Release
Hit:8 http://us.archive.ubuntu.com/ubuntu focal-backports InRelease
Hit:9 https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64 InRelease
Hit:10 http://security.ubuntu.com/ubuntu focal-security InRelease
Hit:1 https://apt.llvm.org/focal llvm-toolchain-focal-12 InRelease
Hit:6 https://apt.llvm.org/focal llvm-toolchain-focal-14 InRelease
Reading package lists... Done
Building dependency tree
Reading state information... Done
19 packages can be upgraded. Run 'apt list --upgradable' to see them.
(torch) sharker@persephone:/etc/apt/sources.list.d$ sudo apt upgrade