无法在 Ubuntu 22.04 WSL2 上安装 CUDA

无法在 Ubuntu 22.04 WSL2 上安装 CUDA

我遵循这里提供的命令链: https://developer.nvidia.com/cuda-downloads?target_os=Linux&target_arch=x86_64&Distribution=WSL-Ubuntu&target_version=2.0&target_type=deb_local 在 wsl2 上安装 cuda (v11.6)。但是,最后三行失败了。以下是终端中的内容:

(base) peter72@Peter72:~$ sudo apt-key add /var/cuda-repo-wsl-ubuntu-11-6-local/7fa2af80.pub
Warning: apt-key is deprecated. Manage keyring files in trusted.gpg.d instead (see apt-key(8)).
OK

(base) peter72@Peter72:~$ sudo apt-get update
Get:1 file:/var/cuda-repo-wsl-ubuntu-11-5-local  InRelease
Ign:1 file:/var/cuda-repo-wsl-ubuntu-11-5-local  InRelease
Get:2 file:/var/cuda-repo-wsl-ubuntu-11-6-local  InRelease
Ign:2 file:/var/cuda-repo-wsl-ubuntu-11-6-local  InRelease
Get:3 file:/var/cuda-repo-wsl-ubuntu-11-5-local  Release
Err:3 file:/var/cuda-repo-wsl-ubuntu-11-5-local  Release
  File not found - /var/cuda-repo-wsl-ubuntu-11-5-local/Release (2: No such file or directory)
Get:4 file:/var/cuda-repo-wsl-ubuntu-11-6-local  Release [564 B]
Get:4 file:/var/cuda-repo-wsl-ubuntu-11-6-local  Release [564 B]
Get:6 http://security.ubuntu.com/ubuntu jammy-security InRelease [110 kB]
Hit:7 https://nvidia.github.io/libnvidia-container/stable/ubuntu18.04/amd64  InRelease
Hit:8 https://nvidia.github.io/nvidia-container-runtime/stable/ubuntu18.04/amd64  InRelease
Hit:9 http://archive.ubuntu.com/ubuntu jammy InRelease
Hit:10 https://nvidia.github.io/nvidia-docker/ubuntu18.04/amd64  InRelease
Hit:11 http://archive.ubuntu.com/ubuntu jammy-updates InRelease
Hit:12 http://archive.ubuntu.com/ubuntu jammy-backports InRelease
Reading package lists... Done
E: The repository 'file:/var/cuda-repo-wsl-ubuntu-11-5-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.
W: file:/var/cuda-repo-wsl-ubuntu-11-6-local/Release.gpg: Key is stored in legacy trusted.gpg keyring (/etc/apt/trusted.gpg), see the DEPRECATION section in apt-key(8) for details.
W: https://nvidia.github.io/libnvidia-container/stable/ubuntu18.04/amd64/InRelease: Key is stored in legacy trusted.gpg keyring (/etc/apt/trusted.gpg), see the DEPRECATION section in apt-key(8) for details.
W: https://nvidia.github.io/nvidia-container-runtime/stable/ubuntu18.04/amd64/InRelease: Key is stored in legacy trusted.gpg keyring (/etc/apt/trusted.gpg), see the DEPRECATION section in apt-key(8) for details.
W: https://nvidia.github.io/nvidia-docker/ubuntu18.04/amd64/InRelease: Key is stored in legacy trusted.gpg keyring (/etc/apt/trusted.gpg), see the DEPRECATION section in apt-key(8) for details.

(base) peter72@Peter72:~$ sudo apt-get -y install cuda
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 libcufile-11-6 : Depends: liburcu6 but it is not installable
E: Unable to correct problems, you have held broken packages.

为了修复这些问题,我下载了另一个 cuda 版本 (v11.5),希望它能正常工作,但结果却不是这样。我还手动删除了 cuda repo 文件夹,这导致了我无法修复的混乱。我尝试清除 cuda 和 nvidia 以尝试重新开始,但没有成功。

答案1

ppa:cloudhan/liburcu6为 Ubuntu 22.04 提供 liburcu6 的正向移植。

sudo add-apt-repository ppa:cloudhan/liburcu6
sudo apt update
sudo apt install liburcu6

然后,您可以继续安装 CUDA 11.6。

答案2

对于 Ubuntu 22,您需要手动安装该库。从以下任何一个镜像下载: https://packages.ubuntu.com/impish/amd64/liburcu6/download

然后sudo apt install ./liburcu6*.deb

那么就应该可以了。

答案3

注意:解决方案在最后一行。不要开始打开链接

apt-key(8)问题可以在这里修复: 什么命令(确切地)应该取代弃用的 apt-key?

但是,这并不能解决问题libcufile-11-6 : Depends: liburcu6 but it is not installable。这是因为如果您尝试使用此处来源的说明安装 libcufile-11-6: https://ubuntu.pkgs.org/20.04/ubuntu-main-amd64/liburcu6_0.11.1-2_amd64.deb.html,使用以下命令你将在终端中获得sudo apt-get install liburcu6

Package liburcu6 is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

E: Package 'liburcu6' has no installation candidate

发生这种情况是因为 liburcu6 在 Ubuntu 版本 22.04 中不受支持或由于某种原因不存在。除此之外,如果您仔细查看同一链接页面的开头,您会发现安装命令适用于 Ubuntu 版本 20.04。

因此,最后,避免所有这些问题的方法是使用 Ubuntu 20.04 而不是 22.04。这样,您就不会遇到任何问题。

答案4

我的建议是,如果你使用的是 Ubuntu 22.04,则只需安装 CUDA 11.7 并忽略以前的版本。当我尝试从 NVIDIA 下载 CUDA 11.6.x 时,很明显他们的说明甚至没有提供 22.04 作为选项。只有当我升级到 11.7 CUDA 时...并且在我的快速测试中...Pytorch 并不关心,即使截至今天它官方仅支持 11.6

相关内容