Install pytorch deep learning environment (GPU version) and pycharm

1. Install or update the graphics card driver

        According to the configuration and needs of your computer, install or update the graphics card driver, nvidia graphics card driver download address: official driver | NVIDIA

        The download may be slow, it would be better if there is a ladder. After the download is complete, install the exe file. After the installation is complete, open the cmd command window and enter the following command to view the graphics card driver information.

nvidia-smi

        According to the graphics card driver information, you can see the driver version and the highest supported CUDA version. Then, we need to install the environment based on this information.

          

 2. Install Anaconda

        We will install pytorch via Anaconda. Anaconda official website address: Anaconda | Anaconda Distribution

Open the official website and download the corresponding installation package according to your computer version.

              

        Double-click the downloaded anaconda installation package and follow the installation steps to install it. There are two things to pay attention to during the installation process. First, choose a suitable installation path; second, add anaconda to the environment variable, as shown in the figure below, and tick it.

                  

         After the installation is complete, click the win key and the Anaconda3 folder will appear, so that anaconda is installed.

                                                     

 3. Install the pytorch environment

        Click the win key to find the Anaconda3 folder, as shown in the figure, open the Anaconda terminal.

                               

        Enter the following command to create a pytorch virtual space. When asked whether to install, enter y.

conda create -n pytorch python=3.9

        Then enter the following command to activate the pytorch environment.

conda activate pytorch

        As shown in the figure, enter the pytorch virtual environment just created.                                  

       Then open pytorch's official website PyTorch . In the first step, we know that the graphics card driver supports up to cuda11.6 version, so we choose cuda11.3 version of cuda, as shown in the figure below, copy the command in the red box.

        Paste the copied content into the terminal under the pytorch environment and run it.​​​​

        Then start to download the dependent packages required by the environment. Downloads may be slower due to website issues. At this point, the deep learning environment of pytorch is installed.

4. Verify

        Open Anaconda's terminal and activate the pytorch environment. Enter the following commands in sequence in the pytorch environment:

python
import torch
torch.cuda.is_available()

        If the output is as follows, the pytorch environment is installed successfully.

 5. Install pycharm

        Open the pycharm official website Download PyCharm , download the community version (free).

                   

        Click the installation package, follow the installation steps, select the appropriate path, check Add to environment variables (you can check all of them on that page), and complete the installation.

        Open the software, create a new project, click Add Interpreter... in the lower right corner

                                          

        Press the red box in the figure to select the corresponding option, and then click OK, then the pytorch environment configuration is complete.

                 

          As shown in the figure, select pytorch.

                                     

         So far, the installation of the deep learning environment based on pytorch has been completed.

Guess you like

Origin blog.csdn.net/cxzgood/article/details/124493492