【docker】WSL+docker_desktop+GPU配置环境失败

尝试windows下使用docker_desktop安装深度学习的GPU环境,结果很失败,GPU调用不了。我一共尝试两种方式调用GPU。

第一种是新版本WSL2直接支持,下载一个Nvidia官方的docker镜像,然后直接输入命令:

docker run -it --gpus=all --rm nvidia/cuda:11.4.2-base-ubuntu20.04 nvidia-smi

报错:

docker: Error response from daemon: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: error during container init: error running hook #0: error running hook: exit status 1, stdout: , stderr: Auto-detected mode as 'legacy'
nvidia-container-cli: initialization error: WSL environment detected but no adapters were found: unknown.

第二种是在WSL2子系统下安装CUDA。

安装成功后nvdia-smi还是运行不了,报错:

Failed to initialize NVML: GPU access blocked by the operating system
Failed to properly shut down NVML: GPU access blocked by the operating system

在网上查了一下这两种报错的原因,可能是由于windows版本不匹配,需要升级到21H2的版本才可以。

目前我的电脑是21H1版,暂时更新不了,这里先记下,回头等更新推送了,我再安装。

附录:安装过程中用到的几个网址和博客:
Nvidia官网cuda on wsl说明书:https://docs.nvidia.com/cuda/wsl-user-guide/index.html
Nvidia-cuda官方Docker镜像库:https://hub.docker.com/r/nvidia/cuda/tags
微软官网wsl说明书:https://docs.microsoft.com/zh-cn/windows/wsl/basic-commands
B站博客:https://www.bilibili.com/read/cv14608547/
CSDN博客1(直接运行命令):https://blog.csdn.net/fleaxin/article/details/108911522
CSDN博客2:https://blog.csdn.net/dongbox_/article/details/122483636
CSDN博客3(windows版本问题导致无法链接GPU):
https://blog.csdn.net/weixin_44121966/article/details/122848667

你可能感兴趣的:(docker,容器,运维,深度学习,GPU环境配置)