Windows安装Pytorch/torchvision

windows linux通用:

1.7.1 支持cuda10.1

pip install torch==1.7.1+cu101 torchvision==0.8.2+cu101 torchaudio==0.7.2 -f https://download.pytorch.org/whl/torch_stable.html
————————————————
版权声明:本文为CSDN博主「AI视觉网奇」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/jacke121/article/details/79825694

可以去官网https://pytorch.org/

直接选择需要的版本,进行下载:

https://pytorch.org/get-started/previous-versions/

下载历史版本whl自己安装,可以选cuda版本:

https://download.pytorch.org/whl/torch_stable.html

Windows下用Anaconda安装Pytorch/torchvision

原文:https://blog.csdn.net/yimingsilence/article/details/79126914

1. 安装Anaconda最新版

2. 依赖的环境

  • Anaconda3 x64 (with Python 3.5/3.6)
  • Windows 64位系统(Windows 7 或 Windows Server 2008 及以上)
  • CUDA 8 / CUDA 9
  • cuDNN v5以上
  • 如果安装了CUDA编译的包,请确保你的电脑有Nvidia的显卡。
  • 注:这里没有介绍GPU版本的安装方法,如需要的请搜索其他博文。

3. 开始菜单打开Anaconda Prompt,在里面输入conda create -n pytorch python=3.5,为pytorch创建一个虚拟环境

3.5 添加清华镜像

 conda config --addchannels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/

 conda config --setshow_channel_urls yes

4. activate pytorch 激活这个虚拟环境(取消激活用deactivate)

5. 在这个环境中,

# for CPU only packages
conda install -c peterjc123 pytorch

# for Windows 10 and Windows Server 2016, CUDA 8
conda install -c peterjc123 pytorch cuda80

# for Windows 10 and Windows Server 2016, CUDA 9
conda install -c peterjc123 pytorch cuda90

# for Windows 7/8/8.1 and Windows Server 2008/2012, CUDA 8
conda install -c peterjc123 pytorch_legacy cuda80

5.5. torch安装好了其实还是需要torchvision的

使用本地安装的方法,先下载安装包

https://pypi.python.org/pypi/torchvision/0.1.8

然后在安装包所在的目录中用下面的命令安装:

pip install 下载的安装包的名字.whl

6. 测试torch

在Anaconda Prompt 里面打开python 然后键入import torch
还有 import torchvision

7. 测试CUDA和cuDNN

# CUDA TEST
import torch
x = torch.Tensor([1.0])
xx = x.cuda()
print(xx)

# CUDNN TEST
from torch.backends import cudnn
print(cudnn.is_acceptable(xx))

8. 如果CUDA工作不正常,就要关掉了

cudnn.enabled = False

9. over

你可能感兴趣的:(深度学习基础)