Skip to content

Update pytorch.md -- Add torch tsinghua source #37

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Aug 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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