wsl2 安装,支持gpu
ref:
https://docs.microsoft.com/zh-cn/windows/wsl/install
https://devblogs.microsoft.com/commandline/install-wsl-with-a-single-command-now-available-in-windows-10-version-2004-and-higher/
https://docs.nvidia.com/cuda/wsl-user-guide/index.html
0 要求
系统更新到2004以上, 我这里用的 21H2
1 打开虚拟环境,安装ubuntu
管理员权限打开 powershell, 运行 wsl --list --online 查看在线的发布包,然后运行
wsl --install -d Ubuntu-18.04
等进度条跑完,安装好就可以重启了
2 更新win10 系统的cuda驱动
在下面网站里下载
https://www.nvidia.com/download/index.aspx
然后在windows中安装即可, 安装好后在wsl里就可以用 nvidia-smi 显示GPU , nvcc还不支持
3 在WSL环境中安装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
wget https://developer.download.nvidia.com/compute/cuda/repos/wsl-ubuntu/x86_64/cuda-wsl-ubuntu.pin
sudo mv cuda-wsl-ubuntu.pin /etc/apt/preferences.d/cuda-repository-pin-600
wget https://developer.download.nvidia.com/compute/cuda/11.7.0/local_installers/cuda-repo-wsl-ubuntu-11-7-local_11.7.0-1_amd64.deb
sudo dpkg -i cuda-repo-wsl-ubuntu-11-7-local_11.7.0-1_amd64.deb
sudo cp /var/cuda-repo-wsl-ubuntu-11-7-local/cuda-*-keyring.gpg /usr/share/keyrings/
sudo apt-get updatesudo
apt-get -y install cuda
顺利安装完的话, 就可以装python环境,跑训练了