admin管理员组

文章数量:1531321

最近需要学习pytorch的东西,进一步开发需要的神经网络模型,在此以这一篇博文作为安装笔记。
pytorch 官网上只有linux和Mac的程序包,没有windows系统的,但是windows系统还是可以用pytorch的。
github: https://github/peterjc123/pytorch-scripts

如果之前安装过GPU版的tensorflow,安装GPU版本的pytorch将会非常容易。
相关参考:
1、查看已安装cuda版本,以及查找cuda与cudnn版本对应关系
https://blog.csdn/huima2017/article/details/81013614
2、如何使用anaconda管理多个版本的python环境(pytorch也建议使用conda进行安装)
https://jingyan.baidu/article/22a299b5e6e4909e18376a4b.html

这里我推荐两种安装方式,一种是使用anaconda作为开发环境,一种是直接使用控制台或者命令行(shell,cmd,powershell等)进行安装。

首先是第一种安装方法:

第一步安装anaconda:

推荐清华镜像
https://mirrors.tuna.tsinghua.edu/anaconda/archive/
拖到最后,下载最新版即可。

安装完毕要安装pytorch运行环境:

# If your main Python version is not 3.5 or 3.6
conda create -n test python=3.6 numpy pyyaml mkl
 
 
  • 1
  • 2

然后是安装gpu版本,pytorch:

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

因为TensorFlow只能用 CUDA8,所以我安装的是 cuda8,你也可已安装新版本试试

安装Visual C++ 2015 64 bit

https://www.microsoft/zh-cn/download/details.aspx?id=48145
有就不用装了,一般玩游戏都有的。

下载安装Cuda Toolkit 8.0

https://developer.nvidia/cuda-downloads

因为TensorFlow只能用 CUDA8,我装的8.0,不过听说pytorch支持9.0,可以尝试。

下载8.0:

选择版本:

两个都要下载:

下载完毕安装就行了。

安装cuDNN

官网维护了,度盘链接在此:
https://pan.baidu/s/1nwAYgIl

解压后覆盖到Cuda Toolkit 8.0安装目录中,这样就可以使用了。

测试一下:
打开python,输入如下代码:

import torch
torch.cuda.is_available()
 
 
  • 1
  • 2

返回True证明成功了。

结束。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。

一般来说,使用上述anaconda作为管理工具来安装这些深度学习工具不会出什么问题,接下来,介绍使用第二种方法(命令行或者控制台)来进行安装,不需要借助conda命令。

第一步:安装vs2015(参照上述vs安装)
或者看看这个作为了解(编译器与cuda驱动):
https://blog.csdn/cmat2/article/details/80407059

第二步:安装cuda与cudnn(版本对应关系参见上文安装方式)

第三步:pip install http://download.pytorch/whl/cu90/torch-0.4.0-cp35-cp35m-win_amd64.whl
其中的参数相信大家自己能够看明白。。
进一步可参考:
1、https://blog.csdn/u011622208/article/details/80275344
2、https://wwwblogs/Thinker-pcw/p/8543440.html(讲真这个网盘有点不太靠谱,还是多看看官网吧。。)
3、https://pytorch/
4、https://ptorch/

按道理应该是可以正常安装,控制台进入python环境,
执行:
如果报以上错误,则说明你需要看看这个(没事多查查资料。。):
1、https://blog.csdn/xwy990/article/details/80995893
2、https://blog.csdn/HY_JT/article/details/85336946
3、https://blog.csdn/sinat_30618203/article/details/109709419
4、https://blog.csdn/a529975125/article/details/89644841
5、https://blog.csdn/PSpiritV/article/details/123796341
6、https://blog.csdn/zilangch/article/details/112499472

conda对cuda的安装还是很简约的,比如可以试试conda install pytorch==0.4.1 cudatoolkit=9 -c pytorch去自定义下安装命令。
GPU硬件太高了,有些东西装了也没用。
版本不对,有些算子也用不了。
python版本环境也很重要。

应该就能完美解决问题了。

以上。

本文标签: WindowsGPUPytorch