PyTorch安装

安装方法:

1、安装anaconda

2、conda create --name pytorch_cpu python=3.7(创建一个专门的虚拟环境,既然是虚拟环境,可以统一创建为3.7)

3、进入 conda activate pytorch_cpu

3、pip install torch -i https://mirrors.aliyun.com/pypi/simple/

​ or conda install pytorch

4、pip install torchvision -i https://mirrors.aliyun.com/pypi/simple/

问题:如果安装torchvision 失败,要求指定版本的pytorch;,然后继续安装 torchvision

​ 使用pip install torch==1.4.0 or conda install pytorch == 1.4.0

验证

python

import torch

import torchvision

conda info --envs

conda remove -n your_env_name(虚拟环境名称)

原文地址:https://www.cnblogs.com/fushengliuyi/p/14648299.html