分享

docker- 在 Windows 10 + WSL2 上运行 nvidia-docker

 netouch 2023-07-11 发布于北京

我看到了几个关于这个主题的问答,并尝试了这两种方法。任何关于如何继续任何一条路线的建议表示赞赏:
从 WSL2 中运行 nvidia-docker
我关注了 NVIDIA docsthis tutorial .一切安装和docker命令从 Ubuntu 20.04 中运行。然而,sudo service docker start返回:docker: unrecognized service 更新 :
这变成了 known issue .我能够按照 these instructions 在 Ubuntu 上安装和运行 docker .但是,接下来我遇到了 issue like this

$docker run --gpus all nvcr.io/nvidia/k8s/cuda-sample:nbody nbody -gpu -benchmark
Status: Downloaded newer image for nvcr.io/nvidia/k8s/cuda-sample:nbody
docker: Error response from daemon: OCI runtime create failed: container_linux.go:370: starting container process caused: process_linux.go:459: container init caused: Running hook #0:: error running hook: exit status 1, stdout: , stderr: nvidia-container-cli: initialization error: nvml error: driver not loaded: unknown.
ERRO[0065] error waiting for container: context canceled
  • WSL1 here 也有类似的问题,建议安装 WSL2 的地方。我在 WSL2 下遇到了同样的事情。


  • 从 Windows 运行 NVIDIA docker:


  • 另一个

  • school of thought
  • 建议从 WSL Ubuntu 中删除 docker 并改为运行 Windows docker。然后可以从 WSL 连接到它。好吧,我无法运行

  • nvidia-docker
  • 完全来自 Windows:

  • $ docker run --gpus all nvcr.io/nvidia/k8s/cuda-sample:nbody nbody -gpu -benchmark
    Unable to find image 'nvcr.io/nvidia/k8s/cuda-sample:nbody' locally
    nbody: Pulling from nvidia/k8s/cuda-sample
    ...
    docker: Error response from daemon: could not select device driver "" with capabilities: [[gpu]].
  • 有关于如何修复它的提示 here ,但这完全是关于在 Linux 中运行的 docker。哪个不起作用(见上文)。


  • 此外,从 ubuntu 中删除 docker 后,我仍然可以从 Ubuntu20.04 或运行时运行 docker

  • wsl
  • 来自 Powershell:

  • $ which docker
    /mnt/c/ProgramData/DockerDesktop/version-bin/docker
    $ docker 
    The command 'docker' could not be found in this WSL 2 distro.
    We recommend to activate the WSL integration in Docker Desktop settings.
    
    See https://docs./docker-for-windows/wsl/ for details.
  • 我已经在 Docker 设置的两个不同选项卡中为 Ubuntu 20.04 启用了基于 WSL2 的引擎和集成。


  • 系统

  • Windows 10
    WSL 2
    Ubuntu 20.04 within WSL2
    Windows Docker with WSL2-based engine and integration enabled
  • 非常感谢如何进一步诊断它的任何帮助

最佳答案

我认为在 WSL2 上运行 nVidia GPU (CUDA) 的最佳方法是遵循 nVidia 文档中的教程 CUDA on WSL .您需要按顺序正确执行三件事:

  • 首先,检查您的Windows是否有更新,如果有则更新。那么你需要订阅Microsoft Windows Insider Program , 特别订阅 Dev Channel (Fast ring)。确保将其设置为 Dev channel ,而不是 Beta channel 或 Release Preview channel 。这对我来说是棘手的部分,在您选择 Dev channel 后,通过运行 (winver) 程序检查您的 Windows 版本(在 Windows 的搜索栏中搜索它)如果它低于 20145,请重新检查您的 Windows 以获取更新(您将请参阅更新说明版本 20145 以上可用)。您需要安装它,在这里您需要耐心等待,因为下载和安装更新需要一些时间,它会要求您重新启动 Windows。重新启动后,您就可以开始使用了(您还会注意到两个版本的 Windows 之间存在一些设计差异)。用 (winver) 再次检查您的 windows 版本以找到它,它确实在 20145 以上。

  • 接下来,安装 the NVIDIA preview driver for WSL 2 ,这是一个非常直接的过程。

  • 最后,从 tutorial 安装 WSL2 ,这也是非常直接的过程。就个人而言,我关注了这个 youtube教程来自 David Bombal channel 。


  • 正确执行这三个步骤后,您可以按照 nVidia 教程

  • from Setting up CUDA Toolkit
  • 进行操作。 .


  • 这是另一个

  • nVidia document
  • 陈述您在第 8 章中面临的相同问题。他们声称

  • This error usually indicates that the right Microsoft Windows Insider Preview Builds, WSL 2, NVIDIA drivers and NVIDIA Container Toolkit may not be installed correctly.
  • 对我来说,这是我的 Windows Insider Preview Builds 版本没有正确设置为 20145 或更高版本。

关于docker - 在 Windows 10 + WSL2 上运行 nvidia-docker,我们在Stack Overflow上找到一个类似的问题: https:///questions/65295415/        

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多