一、下载安装Anaconda
清华源镜像下载地址:https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/
一直next即可
查看conda版本:conda --version
查看python版本:python -V
二、安装TensorFlow
打开Anaconda Prompt,安装TensorFlow。由于镜像问题会导致安装TensorFlow一直失败,可以修改镜像,很快安装
配置清华源:
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
打开C:\Users\Administrator\.condarc文件,删除两行代码:
ssl_verify: true
- defaults
然后再输入: conda create -n tensorflow python=3.6
安装成功。
测试环境:
安装TensorFlow-cpu版本,执行命令pip install -i https://pypi.tuna.tsinghua.edu.cn/simple tensorflow
安装成功
查看pip安装的都有哪些包:pip list
三、安装pytorch
pytorch官网
在Anaconda Prompt输入对应指令
1. 选择指定版本pytorch
2. 安装对应版本的torchvision
我安装的是cpu版本
conda install pytorch-cpu==1.1.0 torchvision-cpu==0.3.0 cpuonly -c pytorch
GPU可以参考指令
conda install pytorch==1.1.0 torchvision==0.3.0 cudatoolkit=10.0 -c pytorch
3. 验证torch安装
python
import torch
torch.__version__
exit()
说明安装成功