# WIN10配置WSL2调用GPU **Published by:** [Hans](https://paragraph.com/@dr-ai/) **Published on:** 2021-12-30 **URL:** https://paragraph.com/@dr-ai/win10-wsl2-gpu ## Content 前后搞了几天吧,一直无法在WSL中成功调用gpu,官方的tutorial都翻烂了。最后的最后在近邻发狂的边缘,看到某位网友说WIN10上用WSL调用GPU,系统必须是21H2版本。WIN+R输入winver查了一下我的是20H2,问题发现了。现在回过头想想官方tutorial真的屎啊,喊你加入预览者计划,但是不告诉你要手动更新系统版本,我特么就傻傻的研究了好几天。 这里记录一下大概的配置流程去这里[https://insider.windows.com/en-us/getting-started#register]注册参加预览者计划;在设置→更新和安全→Windows更新中,找到并更新系统到21H2。在win系统里下载安装包含wsl的cuda驱动[https://developer.nvidia.com/cuda/wsl/download]安装更新wsl,并升级到版本2 [https://docs.microsoft.com/en-us/windows/wsl/install-manual]去Microsoft Store 搜索Ubuntu,安装好后打开启动一个容器,设置好用户名和密码。在WIndows PowerShell里运行wsl -l -v 确认Ubuntu容器版本为2。在容器内安装CUDA,注意容器内不需要安装驱动 [https://docs.nvidia.com/cuda/wsl-user-guide/index.html#installing-nvidia-drivers]。从4.2.6 Building Your Own GPU-accelerated Application on WSL 2 开始就好。添加环境变量vim ~/.bashrc 写入 export CUDA_HOME=/usr/local/cuda export LD_LIBRARY_PATH=${CUDA_HOME}/lib64 export PATH=${CUDA_HOME}/bin:${PATH} 退出vim source ~/.bashrc 这时应该就可以正常使用下面两句命令了。nvcc --version nvidia-smi 如果上面第二步没有更新系统,nvidia-smi会提示因为系统限制,无法调用GPU设备。 ## Publication Information - [Hans](https://paragraph.com/@dr-ai/): Publication homepage - [All Posts](https://paragraph.com/@dr-ai/): More posts from this publication - [RSS Feed](https://api.paragraph.com/blogs/rss/@dr-ai): Subscribe to updates - [Twitter](https://twitter.com/hans_rss3): Follow on Twitter