无法在 Ubuntu 22.04 WSL2 上安装 CUDA

Pet*_*heb 5 nvidia cuda windows-subsystem-for-linux

我遵循此处提供的命令链: 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.
Run Code Online (Sandbox Code Playgroud)

在尝试修复它们时,我下载了另一个 cuda 版本(v11.5),希望它能够工作,但它没有。我还手动删除了 cuda repo 文件夹,这导致了我无法修复的混乱。我尝试清除 cuda 和 nvidia 以尝试重新开始,但没有成功。

Pet*_*heb 1

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

问题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
Run Code Online (Sandbox Code Playgroud)

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

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