python3.6下各版本pytorch安装命令

 
# 修改源为清华大学软件镜像站
# 编辑配置文件
vim ~/.condarc
# 更改为以下内容

channels:
  - defaults
show_channel_urls: true
default_channels:
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r
custom_channels:
  conda-forge: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  msys2: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  bioconda: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  menpo: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  pytorch: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  simpleitk: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
# 使得当前配置生效
source ~/.condarc
# 安装pytorch
# cuda 8.x
conda install pytorch torchvision cudatoolkit=8.0 -c pytorch
# cuda 9.0
conda install pytorch torchvision cudatoolkit=9.0 -c pytorch
# cuda 10.0
conda install pytorch torchvision cudatoolkit=10.0 -c pytorch

# 测试是否安装成功
import torch
import torchvision

# 若正常则返回 tensor(1., device='cuda:0')
a = torch.tensor(1.)
a.cuda()

# 若正常则静默
from torch.backends import cudnn

# 若正常则返回 True
cudnn.is_available()

# 若正常则返回 True
cudnn.is_acceptable(a.cuda())