Home  >  Article  >  Backend Development  >  Detailed explanation of PyTorch installation guide

Detailed explanation of PyTorch installation guide

coldplay.xixi
coldplay.xixiforward
2020-11-24 16:32:194396browse

##python video tutorialColumn introduces the installation guide of PyTorch

Detailed explanation of PyTorch installation guide

##Related free learning recommendations:
python video tutorial

This blog mainly introduces the creation of the
PyTorch

environment in the Anaconda virtual environment. The Anaconda software has been successfully installed by default.

Anaconda Inpidual Edition

official download link:https://www.anaconda.com/products/inpidual

According to your own operating system , select the required version number, and then install it in a fool-proof manner. For specific installation and use, please refer to the following link:

https://blog.csdn.net/ITLearnHall/article/details/81708148

Create a virtual environment for PyTorch

Find

Anaconda Prompt

in [Recently Added] and open it, enter the following commands in sequence: <pre class="brush:php;toolbar:false"># 创建名为 PyTorch_envs 的虚拟环境,并指定 Python 版本号为 python 3.8 conda create -n PyTorch_envs python=3.8 # 激活虚拟环境 PyTorch_envs conda activate PyTorch_envs # 退出虚拟环境 conda deactivate</pre>

Install PyTorch in the virtual environment

Open the

PyTorch

official website and choose to install. [Here we choose the official website installation method. Bloggers have also tried other installation methods, but the results are not very good, so it is best to follow the official website installation method. After all, wool comes from the sheep.

Follow the instructions on the official website to install Detailed explanation of PyTorch installation guidePyTorch
. What needs to be noted here is that you must know your CUDA version number before installation, here You can refer to the link https://blog.csdn.net/qq_38295511/article/details/89223169

## My own

CUDADetailed explanation of PyTorch installation guide version number It is
10.1, so choose as shown in the picture. It is recommended to choose the pip

installation method. The operating system should be selected according to your own operating system. I will not go into details here. [It is best to choose a relatively good network environment] If the download speed is very slow, it is recommended to change the source installation. Pay attention to specify the version number. For the specific source change method, please refer to:

https://blog.csdn. net/Ginomica_xyx/article/details/109605629

Detailed explanation of PyTorch installation guideVerify whether PyTorch is installed successfully

Official website https://pytorch.org/ get-started/locally/#windows-verification also explains the verification method:

Detailed explanation of PyTorch installation guide As shown in the figure,
PyTorchDetailed explanation of PyTorch installation guide was installed successfully.
Possible problems during the installation process

import torch
Occurrence

ImportError: numpy.core.multiarray failed to import

Cause of error: There is a problem with the version of

numpy

, resulting in the inability to communicate with

PyTorch The version is matched, specifically the numpy version is too low. Solution: Upgrade the version of numpy

. After activating the environment, enter the following command:

conda upgrade numpy
End.

##PyTorch Installation Guide

This blog is mainly introduced in AnacondaCreate the

PyTorch

environment in the virtual environment, and the Anaconda software has been successfully installed by default. Anaconda Inpidual Edition official download link:

https://www.anaconda.com/products/inpidualAccording to your own operating system , select the required version number, and then install it in a fool-proof manner. For specific installation and use, please refer to the following link:

https://blog.csdn.net/ITLearnHall/article/details/81708148

Create a virtual environment for PyTorch

Find Anaconda Prompt in

[Recently Added]

and open it, enter the following commands in sequence: <pre class="brush:php;toolbar:false"># 创建名为 PyTorch_envs 的虚拟环境,并指定 Python 版本号为 python 3.8 conda create -n PyTorch_envs python=3.8 # 激活虚拟环境 PyTorch_envs conda activate PyTorch_envs # 退出虚拟环境 conda deactivate</pre>

Install PyTorch in a virtual environment

Open the PyTorch official website and select installation. [Here we choose the official website installation method. Bloggers have also tried other installation methods, but the results are not very good, so it is best to follow the official website installation method. After all, wool comes from the sheep.

Detailed explanation of PyTorch installation guide
Follow the instructions on the official website to install PyTorch. What needs to be noted here is that you must know your CUDA version number before installation, here You can refer to the link

https://blog.csdn.net/qq_38295511/article/details/89223169

Detailed explanation of PyTorch installation guide## My own
CUDA version number It is 10.1, so choose as shown in the picture.

It is recommended to choose the

pip installation method. The operating system should be selected according to your own operating system. I will not go into details here. [It is best to choose a relatively good network environment] If the download speed is very slow, it is recommended to change the source installation. Pay attention to specify the version number. For the specific source change method, please refer to:

https://blog.csdn. net/Ginomica_xyx/article/details/109605629

Detailed explanation of PyTorch installation guide

Verify whether PyTorch is installed successfully

Official website https://pytorch.org/ get-started/locally/#windows-verification also explains the verification method:

Detailed explanation of PyTorch installation guide
Detailed explanation of PyTorch installation guide As shown in the figure,
PyTorch was installed successfully.

Possible problems during the installation process

import torch

Occurrence

ImportError: numpy.core.multiarray failed to import

Cause of error: There is a problem with the version of

numpy, resulting in the inability to communicate with PyTorch The version is matched, specifically the numpy version is too low.

Solution: Upgrade the version of

numpy. After activating the environment, enter the following command:

conda upgrade numpy
End.

The above is the detailed content of Detailed explanation of PyTorch installation guide. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:csdn.net. If there is any infringement, please contact admin@php.cn delete