Skip to content

Commit d3127ff

Browse files
authored
Merge pull request #37 from Geniusyingmanji/main
Update pytorch.md -- Add torch tsinghua source
2 parents 932221a + fd9e149 commit d3127ff

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

src/ai/pytorch.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,47 @@
11
# PyTorch
2+
## Installation
3+
### 根据OS和cuda选择适配的torch版本
4+
https://pytorch.org/get-started/previous-versions/
5+
### pip
6+
#### 安装最新版
7+
```shell
8+
pip install torch torchvision torchaudio -i https://pypi.tuna.tsinghua.edu.cn/simple
9+
```
10+
#### 指定版本(preffered)
11+
创建名为pytorch310的虚拟环境
12+
```shell
13+
conda create -n pytorch310 python==3.10
14+
```
15+
激活环境
16+
```shell
17+
conda activate pytorch310
18+
```
19+
设置清华源,加速安装
20+
```shell
21+
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
22+
```
23+
指定版本安装
24+
```shell
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
28+
添加清华镜像源
29+
```shell
30+
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
31+
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
32+
conda config --set show_channel_urls yes
33+
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
34+
```
35+
#### 安装最新版
36+
```shell
37+
conda install pytorch torchvision torchaudio cudatoolkit=10.2
38+
```
39+
#### 指定版本
40+
```shell
41+
conda install pytorch==2.4.0 torchvision==0.19.0 torchaudio==2.4 cudatoolkit=10.2
42+
```
43+
44+
## Tutorial
245
- [pytorch examples](https://github.com/pytorch/examples)
346
- [pytorch tutorials](https://github.com/pytorch/tutorials)
447
- pytorch模型性能分析和优化: [weixin](https://mp.weixin.qq.com/s/lxJthBk1L2nYOyQyLbqqEw)

0 commit comments

Comments
 (0)