三步安装pytorch-cpu(win10下安装pytorch-cpu)

开发环境:

win10 x64位

anaconda3-4.0.0

虚拟环境python版本 3.6.5(安装过程中根据你安装的pytorch版本可能需要升级)

 

前提:anaconda已配置好环境变量,使用conda切换到需要安装pytorch的虚拟环境。

 

第一步:anaconda改为国内源(如果已经改过,请检查添加的国内源中是否有pytorch的源(下方代码中倒数第二行),如果没有请添加国内pytorch源)

conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/msys2/ 
 
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/ 
 
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 --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/peterjc123/
 
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
 
conda config --set show_channel_urls yes

第二步:搜索可用版本

conda search pytorch-cpu

执行结果:(因为时间不一样可能会有新的版本发布,所以搜索结果可能也不一样)

从搜索结果可以看到,共搜索到0.4.0、0.4.1、1.0.0、1.1.0四个版本,但并不是版本越高越好,版本越高可能稳定性越差(猜测),所以尽量找中间版本或者根据需要进行安装,这里我选择安装0.4.1版本。

第三步:安装

# 先安装pytorch-cpu
conda install pytorch-cpu=0.4.1

# 然后安装依赖torchvision-cpu,这里不需要指定版本
conda install torchvision-cpu

运行结果:(视网速,安装过程有快有慢,耐心多等待一会)

 

 

全程无报错,到此,安装就算完成了。

最后,验证:

 

导入无报错,安装成功。

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章