pytorch安装小白教程(创建虚拟环境以及成功安装cuda10.2)——anaconda安装pytorch

 安装前准备,打开anaconda prompt

 

anaconda安装pytorch

(base) C:\Users\Xzy的matebook>conda info --env //查看已安装的环境
# conda environments:
#
base                  *  D:\develop\tool\anaconda3
d2l                      D:\develop\tool\anaconda3\envs\d2l
unet                     D:\develop\tool\anaconda3\envs\unet


(base) C:\Users\Xzy的matebook>conda create -n dl python=3.6 //创建名称为dl的环境
Retrieving notices: ...working... done
Channels:
 - https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
 - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
 - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
 - defaults
Platform: win-64
Collecting package metadata (repodata.json): done
Solving environment: done

## Package Plan ##

  environment location: D:\develop\tool\anaconda3\envs\dl

  added / updated specs:
    - python=3.6


The following packages will be downloaded:

    package                    |            build
    ---------------------------|-----------------
    pip-21.3.1                 |     pyhd8ed1ab_0         1.2 MB  https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/ce
    python-3.6.15              |h39d44d4_0_cpython        18.9 MB  https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/e
    python_abi-3.6             |          2_cp36m           4 KB  https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/ce
    setuptools-58.0.4          |   py36ha15d459_2         959 KB  https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/ce
    vc-14.3                    |      h8a93ad2_21          17 KB  https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/ce
    vc14_runtime-14.40.33810   |      ha82c5b3_21         734 KB  https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/ce
done
#
# To activate this environment, use
#
#     $ conda activate dl
#
# To deactivate an active environment, use
#
#     $ conda deactivate


(base) C:\Users\Xzy的matebook>activate dl  //激活刚刚创建的dl环境,下面三行为添加清华园安装pytorch

(dl) C:\Users\Xzy的matebook>conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
Warning: 'https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/' already in 'channels' list, moving to the top

(dl) C:\Users\Xzy的matebook>conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
Warning: 'https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/' already in 'channels' list, moving to the top

(dl) C:\Users\Xzy的matebook>conda config --set show_channel_urls yes

(dl) C:\Users\Xzy的matebook>conda install pytorch==1.10.0 torchvision==0.11.0 torchaudio==0.10.0 cudatoolkit=10.2 -c pytorch                   //安装pytorch
Channels:
 - pytorch
 - 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/cloud/conda-forge
 - defaults
Platform: win-64
Collecting package metadata (repodata.json): done
Solving environment: done

## Package Plan ##

  environment location: D:\develop\tool\anaconda3\envs\dl

  added / updated specs:
    - cudatoolkit=10.2
    - pytorch==1.10.0
    - torchaudio==0.10.0
    - torchvision==0.11.0


The following packages will be downloaded:

    package                    |            build
    ---------------------------|-----------------
    blas-1.0                   |              mkl           6 KB  https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/man
    cudatoolkit-10.2.89        |       h74a9793_1       317.2 MB  https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/man
    dataclasses-0.8            |     pyh4f3eec9_6          22 KB  https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/man
    freetype-2.12.1            |       ha860e81_0         490 KB  https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/man
    giflib-5.2.1               |       h8cc25b3_3          88 KB  https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/man
    intel-openmp-2023.1.0      |   h59b6b97_46320         2.7 MB  https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/man
    jpeg-9e                    |       h827c3e9_3         334 KB  https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/man
    lerc-3.0                   |       hd77b12b_0         120 KB  https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/man
    libdeflate-1.17            |       h2bbff1b_1         153 KB  https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/man
    libpng-1.6.39              |       h8cc25b3_0         369 KB  https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/man
    libtiff-4.5.1              |       hd77b12b_0         1.1 MB  https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/man
    libuv-1.48.0               |       h827c3e9_0         322 KB  https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/man
    libwebp-1.3.2              |       hbc33d0d_0          73 KB  https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/man
    libwebp-base-1.3.2         |       h2bbff1b_0         306 KB  https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/man
    lz4-c-1.9.4                |       h2bbff1b_1         152 KB  https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/man
    mkl-2020.2                 |              256       109.3 MB  https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/man
    mkl-service-2.3.0          |   py36h196d8e1_0          45 KB  https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/man
    mkl_fft-1.3.0              |   py36h46781fe_0         131 KB  https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/man
    mkl_random-1.1.1           |   py36h47e9c7a_0         235 KB  https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/man
    numpy-1.19.2               |   py36hadc3359_0          22 KB  https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/man
    numpy-base-1.19.2          |   py36ha3acd2a_0         3.8 MB  https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/man
    olefile-0.46               |     pyhd3eb1b0_0          34 KB  https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/man
    pillow-8.3.1               |   py36h8f6046a_0         893 KB  https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/man
    pytorch-1.10.0             |py3.6_cuda10.2_cudnn7_0       951.0 MB  pytorch
    pytorch-mutex-1.0          |             cuda           3 KB  pytorch
    six-1.16.0                 |     pyhd3eb1b0_1          18 KB  https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/man
    tk-8.6.14                  |       h0416ee5_0         3.5 MB  https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/man
    torchaudio-0.10.0          |       py36_cu102         2.1 MB  pytorch
    torchvision-0.11.0         |       py36_cu102         8.5 MB  pytorch
    typing_extensions-4.1.1    |     pyh06a4308_0          28 KB  https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/man
    xz-5.4.6                   |       h8cc25b3_1         609 KB  https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/man
    zlib-1.2.13                |       h8cc25b3_1         131 KB  https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/man
    zstd-1.5.5                 |       hd43e919_2         720 KB  https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/man
    ------------------------------------------------------------
                                           Total:        1.37 GB

The following NEW packages will be INSTALLED:

  blas               anaconda/pkgs/main/win-64::blas-1.0-mkl
  cudatoolkit        anaconda/pkgs/main/win-64::cudatoolkit-10.2.89-h74a9793_1
  dataclasses        anaconda/pkgs/main/noarch::dataclasses-0.8-pyh4f3eec9_6
  freetype           anaconda/pkgs/main/win-64::freetype-2.12.1-ha860e81_0
  giflib             anaconda/pkgs/main/win-64::giflib-5.2.1-h8cc25b3_3
  intel-openmp       anaconda/pkgs/main/win-64::intel-openmp-2023.1.0-h59b6b97_46320
  jpeg               anaconda/pkgs/main/win-64::jpeg-9e-h827c3e9_3
  lerc               anaconda/pkgs/main/win-64::lerc-3.0-hd77b12b_0
  libdeflate         anaconda/pkgs/main/win-64::libdeflate-1.17-h2bbff1b_1
  libpng             anaconda/pkgs/main/win-64::libpng-1.6.39-h8cc25b3_0
  libtiff            anaconda/pkgs/main/win-64::libtiff-4.5.1-hd77b12b_0
  libuv              anaconda/pkgs/main/win-64::libuv-1.48.0-h827c3e9_0
  libwebp            anaconda/pkgs/main/win-64::libwebp-1.3.2-hbc33d0d_0
  libwebp-base       anaconda/pkgs/main/win-64::libwebp-base-1.3.2-h2bbff1b_0
  lz4-c              anaconda/pkgs/main/win-64::lz4-c-1.9.4-h2bbff1b_1
  mkl                anaconda/pkgs/main/win-64::mkl-2020.2-256
  mkl-service        anaconda/pkgs/main/win-64::mkl-service-2.3.0-py36h196d8e1_0
  mkl_fft            anaconda/pkgs/main/win-64::mkl_fft-1.3.0-py36h46781fe_0
  mkl_random         anaconda/pkgs/main/win-64::mkl_random-1.1.1-py36h47e9c7a_0
  numpy              anaconda/pkgs/main/win-64::numpy-1.19.2-py36hadc3359_0
  numpy-base         anaconda/pkgs/main/win-64::numpy-base-1.19.2-py36ha3acd2a_0
  olefile            anaconda/pkgs/main/noarch::olefile-0.46-pyhd3eb1b0_0
  pillow             anaconda/pkgs/main/win-64::pillow-8.3.1-py36h8f6046a_0
  pytorch            pytorch/win-64::pytorch-1.10.0-py3.6_cuda10.2_cudnn7_0
  pytorch-mutex      pytorch/noarch::pytorch-mutex-1.0-cuda
  six                anaconda/pkgs/main/noarch::six-1.16.0-pyhd3eb1b0_1
  tk                 anaconda/pkgs/main/win-64::tk-8.6.14-h0416ee5_0
  torchaudio         pytorch/win-64::torchaudio-0.10.0-py36_cu102
  torchvision        pytorch/win-64::torchvision-0.11.0-py36_cu102
  typing_extensions  anaconda/pkgs/main/noarch::typing_extensions-4.1.1-pyh06a4308_0
  xz                 anaconda/pkgs/main/win-64::xz-5.4.6-h8cc25b3_1
  zlib               anaconda/pkgs/main/win-64::zlib-1.2.13-h8cc25b3_1
  zstd               anaconda/pkgs/main/win-64::zstd-1.5.5-hd43e919_2


Proceed ([y]/n)? y


Downloading and Extracting Packages:
pytorch-1.10.0       | 951.0 MB  | #######################################################2                     |  73%
cudatoolkit-10.2.89  | 317.2 MB  | ############################################################################ | 100%
mkl-2020.2           | 109.3 MB  | ############################################################################ | 100%
torchvision-0.11.0   | 8.5 MB    | ############################################################################ | 100%
numpy-base-1.19.2    | 3.8 MB    | ############################################################################ | 100%
tk-8.6.14            | 3.5 MB    | ############################################################################ | 100%
intel-openmp-2023.1. | 2.7 MB    | ############################################################################ | 100%
torchaudio-0.10.0    | 2.1 MB    | ############################################################################ | 100%
libtiff-4.5.1        | 1.1 MB    | ############################################################################ | 100%
pillow-8.3.1         | 893 KB    | ############################################################################ | 100%
zstd-1.5.5           | 720 KB    | ############################################################################ | 100%
xz-5.4.6             | 609 KB    | ############################################################################ | 100%
freetype-2.12.1      | 490 KB    | ############################################################################ | 100%
libpng-1.6.39        | 369 KB    | ############################################################################ | 100%
jpeg-9e              | 334 KB    | ############################################################################ | 100%
libuv-1.48.0         | 322 KB    | ############################################################################ | 100%
libwebp-base-1.3.2   | 306 KB    | ############################################################################ | 100%
mkl_random-1.1.1     | 235 KB    | ############################################################################ | 100%
libdeflate-1.17      | 153 KB    | ############################################################################ | 100%
lz4-c-1.9.4          | 152 KB    | ############################################################################ | 100%
mkl_fft-1.3.0        | 131 KB    | ############################################################################ | 100%
zlib-1.2.13          | 131 KB    | ############################################################################ | 100%
lerc-3.0             | 120 KB    | ############################################################################ | 100%
giflib-5.2.1         | 88 KB     | ############################################################################ | 100%
libwebp-1.3.2        | 73 KB     | ############################################################################ | 100%
mkl-service-2.3.0    | 45 KB     | ############################################################################ | 100%
olefile-0.46         | 34 KB     | ############################################################################ | 100%
typing_extensions-4. | 28 KB     | ############################################################################ | 100%
pytorch-1.10.0       | 951.0 MB  | #######################################################4            pytorch-1.10.0       | 951.0 MB  | #######################################################5          pytorch-1.10.0       | 951.0 MB  | #######################################################7     pytorch-1.10.0 rchpytorcpytorch-1.10.0    pytorcpytorcdone

(dl) C:\Users\Xzy的matebook>python
Python 3.6.15 (default, Dec  3 2021, 18:25:24) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import torch   //导入torch包
>>> torch.__version__   //查看pytorch安装的版本
'1.10.0'
>>> torch.cuda.is_available()   //看当前torch是否可用,True表示安装成功cuda,False表示当前为cpu环境
True

到这里表示安装完成啦!!!!


 安装清华园,在安装pytorch之前安装这个可以更快下载

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 --set show_channel_urls yes
 
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/win-64/

conda操作命令

(dl) C:\Users\Xzy的matebook>conda list  //查看有哪些包,可以看到下面torchvision               0.11.0               py36_cu102    pytorch 安装的cuda10.2版本的pytorch
# packages in environment at D:\develop\tool\anaconda3\envs\dl:
#
# Name                    Version                   Build  Channel
blas                      1.0                         mkl    https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
cudatoolkit               10.2.89              h74a9793_1    https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
dataclasses               0.8                pyh4f3eec9_6    https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
freetype                  2.12.1               ha860e81_0    https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
giflib                    5.2.1                h8cc25b3_3    https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
intel-openmp              2023.1.0         h59b6b97_46320    https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
jpeg                      9e                   h827c3e9_3    https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
lerc                      3.0                  hd77b12b_0    https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
libdeflate                1.17                 h2bbff1b_1    https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
libpng                    1.6.39               h8cc25b3_0    https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
libtiff                   4.5.1                hd77b12b_0    https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
libuv                     1.48.0               h827c3e9_0    https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
libwebp                   1.3.2                hbc33d0d_0    https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
libwebp-base              1.3.2                h2bbff1b_0    https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
lz4-c                     1.9.4                h2bbff1b_1    https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
mkl                       2020.2                      256    https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
mkl-service               2.3.0            py36h196d8e1_0    https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
mkl_fft                   1.3.0            py36h46781fe_0    https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
mkl_random                1.1.1            py36h47e9c7a_0    https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
numpy                     1.19.2           py36hadc3359_0    https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
numpy-base                1.19.2           py36ha3acd2a_0    https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
olefile                   0.46               pyhd3eb1b0_0    https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
pillow                    8.3.1            py36h8f6046a_0    https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
pip                       21.3.1             pyhd8ed1ab_0    https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
python                    3.6.15          h39d44d4_0_cpython    https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
python_abi                3.6                     2_cp36m    https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
pytorch                   1.10.0          py3.6_cuda10.2_cudnn7_0    pytorch
pytorch-mutex             1.0                        cuda    pytorch
setuptools                58.0.4           py36ha15d459_2    https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
six                       1.16.0             pyhd3eb1b0_1    https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
tk                        8.6.14               h0416ee5_0    https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
torchaudio                0.10.0               py36_cu102    pytorch
torchvision               0.11.0               py36_cu102    pytorch
typing_extensions         4.1.1              pyh06a4308_0    https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
ucrt                      10.0.22621.0         h57928b3_0    https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
vc                        14.3                h8a93ad2_21    https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
vc14_runtime              14.40.33810         ha82c5b3_21    https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
vs2015_runtime            14.40.33810         h3bf8584_21    https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
wheel                     0.37.1             pyhd8ed1ab_0    https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
xz                        5.4.6                h8cc25b3_1    https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
zlib                      1.2.13               h8cc25b3_1    https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
zstd                      1.5.5                hd43e919_2    https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main

猜你喜欢

转载自blog.csdn.net/qq_35353972/article/details/142167200