wsl pytorch
时间: 2023-10-16 13:08:07 浏览: 173
要在WSL中安装PyTorch,可以按照以下步骤进行操作:
1. 首先,建立虚拟环境。在WSL终端中运行以下命令:
```
conda create -n pytorch python=3.8
```
2. 激活虚拟环境。运行以下命令:
```
conda activate pytorch
```
3. 安装PyTorch。根据你的需求和环境选择以下其中一种方式进行安装。
- 如果你想安装PyTorch 1.12.1(支持CUDA 11.3),运行以下命令:
```
pip install torch==1.12.1 cu113 torchvision==0.13.1 cu113 torchaudio==0.12.1 --extra-index-url https://download.pytorch.org/whl/cu113
```
- 如果你想安装最新版本的PyTorch(支持CUDA 11.6),运行以下命令:
```
pip3 install torch torchvision torchaudio --pre --extra-index-url https://download.pytorch.org/whl/nightly/cu116
```
4. 安装完成后,你可以验证PyTorch是否成功安装并且CUDA可用。在Python交互环境中,输入以下命令:
```
import torch
torch.cuda.is_available()
```
如果返回True,说明PyTorch已成功安装并且CUDA可用。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* *3* [WSL2+Ubuntu20.04+CUDA11.3+Pytorch 环境搭建](https://blog.csdn.net/m0_47532096/article/details/129272494)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
- *2* [Windows 11/10 WSL2 Ubuntu 20.04 下配置Cuda及Pytorch](https://blog.csdn.net/weixin_45897172/article/details/128364804)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文