PyTorch development environment installed under Windows

Anaconda installation

  Anaconda is a software package for ease of use python established, which contains more than 250 commonly used tool kit, multiple versions of python interpreter and powerful virtual environment management tools, so named Anaconda python family bucket. Anaconda can make the installation, operation and upgrading the environment easier, it is recommended to install and use.

installation steps:

  1. Official website to download the installation package https://www.anaconda.com/distribution/#download-section
  2. Run the installation package
  3. Select the installation path: usually choose the default path, be sure to check the Add Anaconda to the system PATH environment variable (Anaconda will be added to the environment variable), wait for the installation to complete
  4. Verify successful installation: shortcut win + R, open cmd, input Conda, carriage return, if the various information appears, indicating a successful installation.

PyCharm installation

  PyCharm is a powerful Python IDE, have debugging, syntax highlighting, Project management, code branches, smart tips, version control and other functions.

installation steps:

  1. Official website to download the installation package https://www.jetbrains.com/pycharm/ , the installation package is divided into Professional Edition (fee) and Community Edition (free).
  2. Run the installation package.
  3. Selection path, check Add launchers dir to the PATH, check .py, waiting for installation.

CUDA and CuDNN installation (non-essential)

  1. Check for proper GPU, if any, to be installed with the CUDA CuDNN. Only N cuda card support, the following operations may for supported versions cuda:
    the NVIDIA control panel assembly → → → 3D system information provided /NVCUDA.DLL
  2. Enter PyTorch official website https://pytorch.org/ , click GetStarted, view supports CUDA version number.
  3. CUDA enter the official website https://developer.nvidia.com/cuda-toolkit-archive , select the appropriate version of CUDA, select the appropriate operating system, Installer Type select local. Click to download the first file. Run the installation package, the installation is complete without having to create a shortcut.
  4. CUDA verify successful installation: entering the installation path bin folder, copy path, the switch to the command path (e.g. cd C: \ Program Files \ NVIDIA GPU Computing Toolkit \ CUDA \ v10.1 \ bin), then performs nvcc -V, carriage return, if the relevant version of the message, instructions for proper installation.
  5. Enter cuDNN official website https://developer.nvidia.com/rdp/cudnn-download , register and login account, choose the appropriate version to download. Extract the installation package, the inside of the folder to the three CUDA installation path (e.g., C: \ Program Files \ NVIDIA GPU Computing Toolkit \ CUDA \ v10.1), cuDNN installation is complete.
  6. CuDNN verify successful installation: extras command to switch to the installation path \ demo_suite file folder, performing bandwidthTest.exe, carriage return, Result = PASS installation was successful. Continue deviceQuery.exe, enter, display GPU model, Result = PASS, expressed CUDA and cuDNN are installed successfully.

The pip source to replace domestic mirror

  When you use pip to install python toolkit, due to the slow speed default source, it is recommended to switch domestic image.
The default source

  • https://pypi.org/

Domestic Mirror

  • Ali cloud https://mirrors.aliyun.com/pypi/simple/

  • China University of Science and Technology https://pypi.mirrors.ustc.edu.cn/simple/

  • Watercress (douban) https://pypi.douban.com/simple/

  • Tsinghua University https://pypi.tuna.tsinghua.edu.cn/simple/

  • Huazhong University of Science and Technology https://pypi.hustunique.com/

Using temporary
  connection after installation -i url can command, such as: image download with Tsinghua PANDAS
  PIP PANDAS -i https://pypi.tuna.tsinghua.edu.cn/simple the install
permanent changes
  to modify% HOMEPATH% \ pip \ pip. ini file
  % HOMEPATH% generally C: \ Users \ xx
  typically requires PIP new folder, then the new file pip.ini, ini file can be opened and edited with the present note, the following entries in the file pip.ini (mirrored in watercress Case):
  [Global]
  index https://pypi.douban.com/simple-URL =
  [the install]
  Trusted-Host = pypi.douban.com

PyTorch installation

1. Download whl file (optional)
  into the PyTorch official website https://pytorch.org/ , click GetStarted, select the appropriate version, package selection pip, you can see the bottom of the torch and appears torchvision the latest version number, and a URL https : //download.pytorch.org/whl/torch_stable.html , copy the URL, you can see the various versions of the torch installation files, in this way, much more quickly than the speed command to perform the installation. File name is regular, such as:
  cu101 / torch-1.4.0-CP37-cp37m-win_amd64.whl,
  cu101 / torchvision-0.5.0-CP37-cp37m-win_amd64.whl
  as cuda version cu, after the torch to torch version after version after torchvision to torchvision, cp is the python version, the final surface behalf windows64 bit.
  You can use the shortcut key ctrl + F search for the latest version of the torch and torchvision files (such as search cu101 / torch-1.4.0), then select the appropriate python version and platform to download the file pytorch and torchvision of whl, python version to be consistent with the system, in the command line to see the system python python version.
2. PyCharm a new project
  Create New Project → Pure Python → name → Create
  a new script: File → New → Python file → Enter name →
  Enter the following code in the script → Right → Run 'project name' → error can not find torch, because in the current environment, we do not PyTorch installed.

import torch
print("hello pytorch{}".format(torch.__version__))
print(torch.cuda.is_available())

3. Create a python virtual environment
  Click below to enter Terminal → virtual environment conda create -n name python = version number (such as conda create -n pytorch_gpu python = 3.7) → Enter → wait for completion
  into the virtual environment: Enter the name conda activate the virtual environment → enter
4. install
  enter whl file directory: Type cd whl file directory → enter
  : type pip install torch → press the tab key to auto-complete → enter → wait for the successful installation of
     input pip install torchvision → press the tab key to auto-complete Enter the full → → wait for a successful installation
Note: If the first step does not whl download files, direct mounting pip or conda command is displayed after installation in order to select the appropriate version PyTorch official website.
5. The project is currently associated to the newly created virtual environment, choose the python interpreter
  File → Setting → Project: Project Name / Project Interpreter → Settings button → Add → Conda Environment → Existing environment → interpreter select the anaconda installation path / envs / virtual environment name /python.exe→OK→OK→OK→ a few moments to initialize
6. verify
  right-run, successful output PyTorch version. If the output True, prove GPU available.

发布了9 篇原创文章 · 获赞 0 · 访问量 277

Guess you like

Origin blog.csdn.net/SakuraHimi/article/details/104542418