Build pytorch under Anaconda
Python version: 3.7
1. Install any version of Anaconda
First install anaconda Install anaconda under Windows
Enter the folder, select the corresponding anaconda version, select the following version as python3.7 (if you want to install others, select other version numbers)
Anaconda other version folder
After the installation is complete, enter cmd in the search box, open the terminal to see if the installation is successful
Enter python -V
Dangdangdangdang~ Version 3.7 is installed successfully
2. Configure the graphics card NVIDIA
Open the task manager, ctr+Alt+Del, and see if it is displayed. If it is, it means that the driver already exists. If not, just install the driver.
If you don’t have a GPU, pay attention. If you don’t have one, just omit this step and go directly to step 4.
3. Check the cuda version
Open the NVIDIA control panel, how to open it, you can enter NVIDIA in the search box
After opening, select System Information, click Components, and view the corresponding version information.
You don't need to manually install CUDA and cuDNN yourself, the official pytorch has done it very well. Just go to the official website and copy the command.
4. Create a pytorch storage warehouse
The reason for creating it is to separate different versions of pytorch for ease of use. Open the anaconda prompt, create a warehouse called mytorch, or call it another name
conda create -n mytorch python=3.7
Then enter y and press Enter
After the installation is complete, enter
conda info --envs
and then enter conda activate mytorch
to activate the current environment and enter the warehouse just created
5. Install pytorch
Enter the pytorch official website
, pull down to see the page, and select the corresponding pytorch version number according to the version of your computer. The CUDA version
supported by my computer is 11.1.114.
注意,前面没有GPU的这里直接选择CPU即可,不需要再去安装什么CUDA了
Enter the corresponding command in the command line just now
conda install pytorch==1.8.0 torchvision==0.9.0 torchaudio==0.8.0 cudatoolkit=11.1 -c pytorch -c conda-forge
Enter y and press Enter, wait patiently, it will look like this after completion
6. Verify
Next is the verification moment, as shown in the figure below, the installation is successful
#先输入
python
#再输入
import torch
#然后输入
import torchvision
#最后输入
torch.cuda.is_available()