Skip to content

Commit dfda8db

Browse files
Update pytorch.md
1 parent 776ef65 commit dfda8db

File tree

1 file changed

+21
-4
lines changed

1 file changed

+21
-4
lines changed

src/ai/pytorch.md

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,37 @@
33
### 根据OS和cuda选择适配的torch版本
44
https://pytorch.org/get-started/previous-versions/
55
### pip
6+
#### 安装最新版
67
```
7-
安装最新版
88
pip install torch torchvision torchaudio -i https://pypi.tuna.tsinghua.edu.cn/simple
9-
指定torch, cuda版本(preffered)
10-
pip install torch==1.10.0+cu113 torchvision==0.11.1+cu113 torchaudio===0.10.0+cu113 -i https://pypi.tuna.tsinghua.edu.cn/simple
119
```
12-
### conda
10+
#### 指定torch, cuda版本(preffered)
11+
创建名为pytorch310的虚拟环境
12+
```
13+
conda create -n pytorch310 python==3.10
14+
```
15+
激活环境
16+
```
17+
conda activate pytorch310
18+
```
19+
设置清华源,加速安装
20+
```
21+
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
1322
```
23+
指定版本安装
24+
```
25+
pip install torch==2.0.0+cu118 torchvision==0.15.1+cu118 torchaudio==2.0.1+cu118 -f https://download.pytorch.org/whl/torch_stable.html
26+
```
27+
### conda
1428
添加清华镜像源
29+
```
1530
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
1631
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
1732
conda config --set show_channel_urls yes
1833
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
34+
```
1935
安装并指定cuda版本
36+
```
2037
conda install pytorch torchvision cudatoolkit=10.2
2138
```
2239

0 commit comments

Comments
 (0)