Install pytoch on Anaconda of Ubuntu system to teach you how to install an elegant environment (1-5)


1、 Clear premise

First of all, pytorch we installed is CUDA version, so we should first know your CUDA Version (my CUDA is 10.2)

2、 Open the pytorch official website to view the installation commands


I didn’t install the latest version here. I’m afraid it’s unstable



Choose a version that suits you (don’t rush to enter the command first!)

a) Official website installation

conda install pytorch==1.5.0 torchvision==0.6.0 cudatoolkit=10.2 -c pytorch

b) Mirror installation (remove – C)

conda install pytorch==1.5.0 torchvision==0.6.0 cudatoolkit=10.2 pytorch

Make sure you have configured the domestic image of pytorch. If the installation of the domestic image is unsuccessful, try it twice more. If it doesn’t work, you can choose to install it on the official website (personal test! Sometimes the official website installation is not slow!)





3、 Create a new Anaconda environment

conda create -n python36torch15 python=3.6

After the environment is created, enter the command found earlier to install pytorch


4、 Verify installation

Has your CUDA version of pytorch been installed yet? It’s time to witness miracles.

Input in the anaconda environment you created (mine is Python 36 torch 15)


Enter the python coding environment

Input code

#Determine whether CUDA is installed
import torch
print(torch.cuda.is_ Available()) # returns true, indicating CUDA has been installed

——————Here, pytorch will be installed and start your pytorch journey——————




******The following is a gift! I believe you will use it later******

#Determine whether cudnn is installed
from torch.backends import  cudnn 
print(cudnn.is_ Available()) # returns true, indicating that cudnn has been installed


Finally ~ I wish scientific research success!!!