Install anaconda, pycharm, cuda, cudnn, PyTorch-GPU version under windows

Table of contents

1. Anaconda installation and virtual environment creation

1.Download of anaconda

 2.Anaconda installation

3. Create a virtual environment

 3.1 Environment startup

 3.2 Switch mirror source

 3.3 Environment creation

3.4 Activating the environment

 3.5 Delete environment

2. pycharm installation

1.pycharm download

2.Installation of pycharm

3. Installation of CUDA

1. Correspondence between GPU version and CUDA version, cudnn version, and graphics card driver

1.1 First check your graphics card

1.2cuda and driver comparison table

1.3 Download cuda 

 1.4cuda installation

4. Installation of CUDNN

1.cudnn download

1.2cudnn installation

5. Installation of pytorch

1.1 Install using pytorch official website

1.2.pytorch verification


1. Anaconda installation and virtual environment creation

1.Download of anaconda

Anaconda official website: https://www.anaconda.com
Tsinghua University open source mirror download: https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/

Anaconda can be downloaded through the above two methods. The one downloaded through the official website of anaconda is the latest version. There is a problem here that the python version is generally the latest, that is, the python version of the generated conda base environment is the latest. This seems to be It cannot be downgraded. I have tried many versions but cannot do it. However, it does not affect the overall situation. We can create our own environment to install a version of python that suits our own.

 2.Anaconda installation

This is relatively simple, basically just take the next step. Since there is no screenshot during installation, let’s put a csdn link for now.

(121 messages) Anaconda installation tutorial (super detailed version)_Installing anaconda_EEdith's blog-CSDN blog

3. Create a virtual environment

Since the environment that comes with conda after installation may not be suitable for our needs, it is generally necessary to create one or more virtual environments. Here are some commonly used commands:

grammar Function
conda --version View conda version number
python --version View python version number
conda info --envs View a list of virtual environments
conda create -n virtualname pip python=3.6 Create a virtual environment and specify the python version number
conda activate virtualname Activate virtual environment
conda disabled Exit the virtual environment
conda remove --name virtualname --all Delete virtual environment

 3.1 Environment startup

The conda environment is started through the program in the start menu, as shown below:

 After startup it is as follows:

 3.2 Switch mirror source

If you download directly, you will be subject to many restrictions and the download speed will be very full. Generally, you need to switch the mirror source first. There are many domestic mirror sources. Generally, the Tsinghua mirror source is used more. If you have any problems, you can search for other ones online and leave them aside for now. For Tsinghua University, the specific orders are as follows:

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/

Be sure to restore the default before switching to other mirror sources. The command is as follows:

conda config --remove-key channels

 3.3 Environment creation

 There are two points to note when creating an environment. One is the environment name, which can be set according to your own needs. The second is the python version. What we need to install here is version 3.7.

conda create -n virtualname pip python=3.7

3.4 Activating the environment

 3.5 Delete environment

Also record the statement to delete the environment, and be sure to add all after it.

conda remove -name virtualname --all 

2. pycharm installation

1.pycharm download

pycharm official website: Download PyCharm: Python IDE provided by JetBrains for professional developers

I won’t talk about the activation of pycharm here for the time being.

2.Installation of pycharm

Regarding the installation of pycharm, please also post the URL you found.

(121 messages) PyCharm installation tutorial_Xiaobai’s blog for learning CS-CSDN blog

3. Installation of CUDA

1. Correspondence between GPU version and CUDA version, cudnn version, and graphics card driver

1.1 First check your graphics card

nvidia-smi

Here we focus on the graphics card driver. You will need to find the corresponding cuda version on the official website later.

1.2cuda and driver comparison table

Find the comparison via the following URL

CUDA 12.2 Release Notes (nvidia.com)

1.3 Download cuda 

Go to the cuda official website and choose the cuda version that suits your driver. I chose 12.2 at first. Later, after installing tensorflow and pytorch, I found that this version is higher and needs to be lowered, so you have to choose the one that suits you in advance. Here I will use 11.8 for the time being. For example.

cuda official website download: CUDA Toolkit Archive | NVIDIA Developer

 1.4cuda installation

If you don’t have a screenshot, just take the next step and post the URL you found.

Installation of cuda under windows - wenglabs - Blog Park (cnblogs.com)

4. Installation of CUDNN

1.cudnn download

Select the corresponding cudnn version on the official website. This version must first correspond to cuda, and then if tensorflow is installed, it must also correspond to tensorflow.

Official website: cuDNN Download | NVIDIA Developer

cudnn comparison: 

tensorflow comparison URL: Build from source on Windows | TensorFlow (google.cn)

 Find the cudnn that suits you based on the comparison above, and then download it

1.2cudnn installation

The download is a compressed package. After decompression, there are three folders in it.

Copy the files in the cuDNN directory to the directory of the corresponding version of CUDA. I have installed several versions, so I took a screenshot of 11.2.

 

 After completion, add environment variables and add C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.2\lib\x64 to path

5. Installation of pytorch

1.1 Install using pytorch official website

Open the official website, select the corresponding version, and the execution statement will be automatically generated and executed in the corresponding conda environment.

Start Locally | PyTorch

Note: If you have already installed the CPU version of pytorch, you need to manually delete it first and then install it again, otherwise it will not be successful.

1.2.pytorch verification

Use the following statement to verify. If the return value is true, it is successful. If it is false, you need to check the compatibility between the driver, cuda, cudnn, and torch.

import torch
print(torch.__version__)
print(torch.cuda.is_available())

The installation is now complete.

 

Guess you like

Origin blog.csdn.net/matlab001/article/details/132034291