Skip to content

Commit

Permalink
Merge pull request #37 from Geniusyingmanji/main
Browse files Browse the repository at this point in the history
Update pytorch.md -- Add torch tsinghua source
  • Loading branch information
ZhikangNiu authored Aug 9, 2024
2 parents 932221a + fd9e149 commit d3127ff
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions src/ai/pytorch.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,47 @@
# PyTorch
## Installation
### 根据OS和cuda选择适配的torch版本
https://pytorch.org/get-started/previous-versions/
### pip
#### 安装最新版
```shell
pip install torch torchvision torchaudio -i https://pypi.tuna.tsinghua.edu.cn/simple
```
#### 指定版本(preffered)
创建名为pytorch310的虚拟环境
```shell
conda create -n pytorch310 python==3.10
```
激活环境
```shell
conda activate pytorch310
```
设置清华源,加速安装
```shell
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
```
指定版本安装
```shell
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
```
### conda
添加清华镜像源
```shell
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
conda config --set show_channel_urls yes
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
```
#### 安装最新版
```shell
conda install pytorch torchvision torchaudio cudatoolkit=10.2
```
#### 指定版本
```shell
conda install pytorch==2.4.0 torchvision==0.19.0 torchaudio==2.4 cudatoolkit=10.2
```

## Tutorial
- [pytorch examples](https://github.com/pytorch/examples)
- [pytorch tutorials](https://github.com/pytorch/tutorials)
- pytorch模型性能分析和优化: [weixin](https://mp.weixin.qq.com/s/lxJthBk1L2nYOyQyLbqqEw)
Expand Down

0 comments on commit d3127ff

Please sign in to comment.