Pytorch 1.3 在Windows下的安装

第一步:下载anaconda,地址:https://repo.anaconda.com/archive/Anaconda3-2019.10-Windows-x86_64.exe

Pytorch 1.3 在Windows下的安装

这里选择window环境下的Python3.7,64位版本,下载后,双击安装包进行安装,安装路径改为:D:\ProgramData\Anaconda3。

第二步:从开始菜单,启动anaconda prompt (anaconda3)命令行,

创建虚拟环境:conda create -n pytorch python=3.7   创建一个名为pytorch的虚拟环境

**虚拟环境:activate pytorch

安装pytorch,登录pytorch官网

Pytorch 1.3 在Windows下的安装

这里选择1.3稳定版本,Windows操作系统,语言为Python3.7,无CUDA

由于官网下载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

 

#添加pytorch源

conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/

# for legacy win-64

conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/peterjc123/

 

复制PyTorch官网命令,并将 -c pytorch删除。

-c pytorch是强制从PyTorch官网下载包,配置的清华源就会失效

#conda install pytorch torchvision cpuonly -c pytorch 官网源命令

conda install pytorch torchvision cpuonly

 

等待安装完成

输入python

Pytorch 1.3 在Windows下的安装

导入torch没有错误,即为安装成功。