[pytorch] win10使用anaconda安装PyTorch1.0

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/zongza/article/details/88885939
  • 首先进入官网,自动检测适合当前电脑的版本:

  • 进入cmd并创建新的虚拟环境
C:\Users\LT> conda create -n pytorch python=3.6

#结果
Solving environment: done


==> WARNING: A newer version of conda exists. <==
  current version: 4.4.7
  latest version: 4.6.8

Please update conda by running

    $ conda update -n base conda



## Package Plan ##

  environment location: D:\tools\Anaconda2\envs\pytorch

  added / updated specs:
    - python=3.6


The following packages will be downloaded:

    package                    |            build
    ---------------------------|-----------------
    pip-19.0.3                 |           py36_0         1.9 MB
    python-3.6.8               |       h9f7ef89_7        20.3 MB
    wheel-0.33.1               |           py36_0          57 KB
    setuptools-40.8.0          |           py36_0         664 KB
    certifi-2019.3.9           |           py36_0         156 KB
    wincertstore-0.2           |   py36h7fe50ca_0          13 KB
    sqlite-3.27.2              |       he774522_0         941 KB
    ------------------------------------------------------------
                                           Total:        24.0 MB

The following NEW packages will be INSTALLED:

    certifi:        2019.3.9-py36_0
    pip:            19.0.3-py36_0
    python:         3.6.8-h9f7ef89_7
    setuptools:     40.8.0-py36_0
    sqlite:         3.27.2-he774522_0
    vc:             14.1-h0510ff6_4
    vs2015_runtime: 14.15.26706-h3a45250_0
    wheel:          0.33.1-py36_0
    wincertstore:   0.2-py36h7fe50ca_0

Proceed ([y]/n)? y


Downloading and Extracting Packages
pip 19.0.3: ################################################################################################### | 100%
python 3.6.8: ###################################################################################################################################################################### | 100%
wheel 0.33.1: ###################################################################################################################################################################### | 100%
setuptools 40.8.0: ################################################################################################################################################################# | 100%
certifi 2019.3.9: ################################################################################################################################################################## | 100%
wincertstore 0.2: ################################################################################################################################################################## | 100%
sqlite 3.27.2: ##################################################################################################################################################################### | 100%
Preparing transaction: done
Verifying transaction: done
Executing transaction: done
#
# To activate this environment, use:
# > activate pytorch
#
# To deactivate an active environment, use:
# > deactivate
#
# * for power-users using bash, you must source
#
  • 进入该虚拟环境并安装一些依赖包
C:\Users\LT>  activate pytorch
(pytorch) C:\Users\LT> pip install numpy pyyaml mkl mkl-include setuptools cmake cffi typing

# 结果
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Collecting numpy
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/ed/29/d97b6252591da5f8add0d25eecda296ea72729a0aad7998edba1981b47c8/numpy-1.16.2-cp36-cp36m-win_amd64.whl (11.9MB)
    100% |████████████████████████████████| 11.9MB 2.2MB/s
Collecting pyyaml
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/72/da/386634cb17f33b12278af017ccb3314cede4806af70285f396b8f6af1203/PyYAML-5.1-cp36-cp36m-win_amd64.whl (214kB)
    100% |████████████████████████████████| 215kB 6.6MB/s
Collecting mkl
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/56/39/537cb3e4e93f1ac5085dc3b3a43cfd99d0af9b29c44fcaa99490f526b611/mkl-2019.0-py2.py3-none-win_amd64.whl (224.1MB)
    100% |████████████████████████████████| 224.1MB 12kB/s
Collecting mkl-include
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/a4/95/63735657ba8eed593b9e77d4c1f04f124f21fabe92ab3aef6c1583ee08b2/mkl_include-2019.0-py2.py3-none-win_amd64.whl (1.0MB)
    100% |████████████████████████████████| 1.0MB 2.2MB/s
Requirement already satisfied: setuptools in d:\tools\anaconda2\envs\pytorch\lib\site-packages (40.8.0)
Collecting cmake
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/af/07/fd33446a4b8ca51f81d805f6a57f9594e24c1b530823a4c7436e4f468219/cmake-3.13.3-cp36-cp36m-win_amd64.whl (29.4MB)
    100% |████████████████████████████████| 29.4MB 20kB/s
Collecting cffi
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/3f/57/e1ba9f697f597cffa35a473c8ad8014b6028f034bdf4d9a91d387cef300e/cffi-1.12.2-cp36-cp36m-win_amd64.whl (170kB)
    100% |████████████████████████████████| 174kB 1.6MB/s
Collecting typing
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/4a/bd/eee1157fc2d8514970b345d69cb9975dcd1e42cd7e61146ed841f6e68309/typing-3.6.6-py3-none-any.whl
Collecting intel-openmp (from mkl)
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/2f/24/2562ec7515e44dea49867fab2c75704c0014d5d3da1f4e9f3bcfac717e5f/intel_openmp-2019.0-py2.py3-none-win_amd64.whl (1.9MB)
    100% |████████████████████████████████| 1.9MB 3.3MB/s
Collecting pycparser (from cffi)
Installing collected packages: numpy, pyyaml, intel-openmp, mkl, mkl-include, cmake, pycparser, cffi, typing
Successfully installed cffi-1.12.2 cmake-3.13.3 intel-openmp-2019.0 mkl-2019.0 mkl-include-2019.0 numpy-1.16.2 pycparser-2.19 pyyaml-5.1 typing-3.6.6
  • 查看cuda版本并下载对应的whl文件(用于building PyTorch)
C:\Users\LT> nvcc --version

# 结果
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2017 NVIDIA Corporation
Built on Fri_Sep__1_21:08:32_Central_Daylight_Time_2017
Cuda compilation tools, release 9.0, V9.0.176
torch-1.0.1-cp36-cp36m-win_amd64.whl下载

链接:https://pan.baidu.com/s/1BS2fu3mKghxrgxxDfQ9cYg 
提取码:7yqs 
复制这段内容后打开百度网盘手机App,操作更方便哦 

  • pip安装PyTorch
(pytorch) C:\Users\LT> pip install C:\Users\LT\Downloads\torch-1.0.1-cp36-cp36m-win_amd64.whl

# 结果
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Processing c:\users\lt\downloads\torch-1.0.1-cp36-cp36m-win_amd64.whl
Installing collected packages: torch
Successfully installed torch-1.0.1

(pytorch) C:\Users\LT> pip install torchvision

# 结果
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Collecting torchvision
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/fb/01/03fd7e503c16b3dc262483e5555ad40974ab5da8b9879e164b56c1f4ef6f/torchvision-0.2.2.post3-py2.py3-none-any.whl (64kB)
    100% |████████████████████████████████| 71kB 655kB/s
Collecting pillow>=4.1.1 (from torchvision)
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/ec/ca/7af5b6628ecf770645f8cc3c9da3c2bb5c5ffc7384a9ff0666fdb818b4d5/Pillow-5.4.1-cp36-cp36m-win_amd64.whl (1.9MB)
    100% |████████████████████████████████| 1.9MB 6.6MB/s
Requirement already satisfied: numpy in d:\tools\anaconda2\envs\pytorch\lib\site-packages (from torchvision) (1.16.2)
Collecting six (from torchvision)
  Using cached https://pypi.tuna.tsinghua.edu.cn/packages/73/fb/00a976f728d0d1fecfe898238ce23f502a721c0ac0ecfedb80e0d88c64e9/six-1.12.0-py2.py3-none-any.whl
Requirement already satisfied: torch in d:\tools\anaconda2\envs\pytorch\lib\site-packages (from torchvision) (1.0.1)
Installing collected packages: pillow, six, torchvision
Successfully installed pillow-5.4.1 six-1.12.0 torchvision-0.2.2.post3
  • 测试是否成功
import torch
print(torch.__version__)
#输出1.0.1
print(torch.cuda.is_available())
#输出true则安装成功

猜你喜欢

转载自blog.csdn.net/zongza/article/details/88885939