首先安装Anaconda:
采用清华镜像下载。网址:
https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/
这里在最后一行选择 Anaconda3-5.1.0-Windows-x86_64.exe 版。
勾选add Anaconda进入系统路径,这样才能用conda命令
然后开始安装pytorch:
首先进入 Pytorch 官网: https://pytorch.org/
按配置选中,得到命令:
但为了使用清华源,需要把-c pytorch取掉,所以命令为:
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/
conda install pytorch torchvision cudatoolkit=10.0
注意cmd需要用管理员权限打开,否则会报错ERROR conda.core.link:_execute(481): An error occurred while uninstalling pa...
然后验证安装是否成功:
python
import torch
然后还要在pycharm中添加新的interpreter:
在这个环境下才有torch可用