[Pytorch] How to install pytorch in Pycharm with pip3 & how to view/install the corresponding version of CUDA Toolkit

【Table of contents】

Check the upper limit of the CUDA Toolkit version corresponding to the graphics card (including GPU)
. Install CUDA Toolkit
and configure the pip3 environment variable. Obtain the pip3 command
from the Pytorch official website
. Install Pytorch in the Pycharm terminal.

1. Check the upper limit of the CUDA Toolkit version corresponding to the graphics card (including GPU)

1. Search for NVIDIA, open NVIDIA Control Panel

2. Open the system information and check the graphics card (NVIDIA GeForce RTX 30600 Laptop GPU as shown below)

3. Select the component and view the upper limit of CUDA Toolkit (as shown in Figure 11.6.134)

2. Install CUDA Toolkit

1. Go to NVIDIA official website to find the corresponding version of CUDA Toolkit (CUDA Toolkit 11.6.0 as shown below)

Official website link: https://developer.nvidia.com/cuda-toolkit-archive

2. Select the corresponding information (Windows x86_64 11 (ie win11) exe (local) as shown below)

3. Click Download

4. Follow the prompts to complete the installation

3. Configure pip3 environment variables

    • Get the path of the folder where pip3 is located (D:\pytorch\pytorchbasis\venv\Scripts as shown below)

2. Open System > System Information, select Advanced System Settings

3. Select environment variables

4. Add the path of the folder where pip3 is located in the Path variable of the user variable or system variable (as described in 1.)

4. Obtain the pip3 command on the Pytorch official website

1.前往Pytorch官网,选择对应信息(如下图Stable(1.13.1) Windows Pip Python CUDA 11.6,复制Run this Command内pip3命令)

官网链接: https://pytorch.org/

五、在Pycharm终端中安装Pytorch

1.打开Pycharm终端,在Pycharm终端中输入pip3,检测pip3是否可用(如下图则可正常使用pip3,若失败请重新尝试配置pip3环境变量)

2.在Pycharm终端中粘贴Pytorch官网的pip3命令(如下图则开始正常安装)

3.安装完成

4.测试,在py文件中输入如下内容并运行(如下图(版本信息请自行判断)则Pytorch安装完成,CUDA配置完成)

Guess you like

Origin blog.csdn.net/weixin_66896881/article/details/128576745