{% note warning::前排提示,搞炸了。有会的兄弟教一下,谢谢。 %}
安装、配置WSL 2
参照前文,完成一个WSL的配置。
安装CUDA on WSL驱动
在官网下载,安装即可,非常的人性化,一路默认即可。
最后在Terminal中输入 nvidia-smi
即可看到类似的输出:
C:\Users\aka> nvidia-smi
Mon Jan 3 10:03:49 2022
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 510.06 Driver Version: 510.06 CUDA Version: 11.6 |
|-------------------------------+----------------------+----------------------+
| GPU Name TCC/WDDM | Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |
| | | MIG M. |
|===============================+======================+======================|
| 0 NVIDIA GeForce ... WDDM | 00000000:01:00.0 Off | N/A |
| N/A 0C P3 20W / N/A | 122MiB / 6144MiB | 0% Default |
| | | N/A |
+-------------------------------+----------------------+----------------------+
+-----------------------------------------------------------------------------+
| Processes: |
| GPU GI CI PID Type Process name GPU Memory |
| ID ID Usage |
|=============================================================================|
| No running processes found |
+-----------------------------------------------------------------------------+
可以看到我们安装的 CUDA 版本是11.6,大于Pytorch官网推荐的11.3,但无伤大雅。
安装Pytorch
在官网选择环境,输入官网给的命令:
conda install pytorch torchvision torchaudio cudatoolkit=11.3 -c pytorch
需要安装的文件列表:
The following NEW packages will be INSTALLED:
cudatoolkit anaconda/pkgs/main/linux-64::cudatoolkit-11.3.1-h2bc3f7f_2
ffmpeg pytorch/linux-64::ffmpeg-4.3-hf484d3e_0
gnutls anaconda/pkgs/main/linux-64::gnutls-3.6.15-he1e5248_0
lame anaconda/pkgs/main/linux-64::lame-3.100-h7b6447c_0
libiconv anaconda/pkgs/main/linux-64::libiconv-1.15-h63c8f33_5
libidn2 anaconda/pkgs/main/linux-64::libidn2-2.3.2-h7f8727e_0
libtasn1 anaconda/pkgs/main/linux-64::libtasn1-4.16.0-h27cfd23_0
libunistring anaconda/pkgs/main/linux-64::libunistring-0.9.10-h27cfd23_0
nettle anaconda/pkgs/main/linux-64::nettle-3.7.3-hbbd107a_1
openh264 anaconda/pkgs/main/linux-64::openh264-2.1.1-h4ff587b_0
pytorch pytorch/linux-64::pytorch-1.10.1-py3.9_cuda11.3_cudnn8.2.0_0
pytorch-mutex pytorch/noarch::pytorch-mutex-1.0-cuda
torchaudio pytorch/linux-64::torchaudio-0.10.1-py39_cu113
torchvision pytorch/linux-64::torchvision-0.11.2-py39_cu113
可以发现是有cuda toolkit的。输入y以安装。 在pytorch处会卡一会,应当是校验。
测试安装
python
import torch
torch.cuda.is_available()
输出应当是True。 不出所料,我这里是False。 炸了,再见。好像是清华镜像的问题。 不搞了,心态没了。