The most detailed installation and configuration of PyTorch entry deep learning environment under Windows (GPU version)

1. Anaconda installation and virtual environment creation

1. Download Anaconda

Anaconda official website: https://www.anaconda.com
Tsinghua University open source mirror download: https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/
Both websites can be downloaded, choose the version suitable for your computer to download That's it.
insert image description here

2. Install Anaconda

insert image description here
insert image description here
Choose to add to the environment variable
and the installation is successful
insert image description here

3. Create a virtual environment

conda create -n 虚拟环境名字 python=版本

conda activate 虚拟环境名字

If you want to delete the virtual environment, enter in the command line window:

conda remove -n 虚拟环境名字 --all

2. Computer configuration, GPU and CUDA preparations

1. Check the computer GPU model and determine the GPU computing power

insert image description here
insert image description here
My graphics card model:
insert image description here

2. Determine the CUDA version according to the computing power

My graphics card computing power corresponds to 6.1
(1) Determine your optional CUDA Runtime Version
(2) Make sure your CUDA Drive version >= CUDA Runtime version.
You can check and find that 9.0 or above is available
insert image description here
(3) Query your own driver CUDA Drive Version
Enter in the anaconda command linenvidia-smi

insert image description here
Mine is 12.1
(4) sure we can apply CUDA
9-12.0

3. You can update the graphics card driver before the first two steps

insert image description here
insert image description here

3. Install Pytorch

1. CUDA version selection

insert image description here
CUDA select the latest 11.7
to copy the installation command (copy Run this Command)
to activate the virtual environment to be installed (conda activate virtual environment name)
and paste the installation command, just wait for a while
insert image description here

2. Verify Pytorch

Activate the virtual environment corresponding to the installation of Pytorch
Enter conda list to see if there is pytorch or torch in the list
insert image description here

Enter python
, enter import torch,
enter torch.cuda.is_available(),
if it displays True, it means that Pytorch is installed successfully
insert image description here

Fourth, install PyCharm and configure it

1. Select the community version

insert image description here
Refer to online installation

2. Connect to the virtual environment created by anaconda

Click New Project, and the New Project
insert image description here
project path can be changed.
insert image description here
Use the virtual environment created by anaconda
insert image description here
After Anaconda configures the virtual environment, you need to add the environment to PyCharm. (Or when creating a new project, set the operating environment for a certain project), choose Conda Environment, sometimes Conda executable is not found error Conda
insert image description here
insert image description here
executable, be sure to choose Conda.exe instead of python.exe, so we have to choose to download in _Conda.exe in the Anaconda root directory, which is the bottom of the picture below (note: the file name is underlined)
insert image description here
Next, because we have created a virtual environment in Anaconda, click Use existing environment and select the installed Anaconda The virtual environment is enough, click OK in the lower right corner, you can
return to the project creation page, click Create, you
can see the virtual environment in the lower right corner,
insert image description here
you're done

5. References

https://blog.csdn.net/qq_43874102/article/details/123164105
https://blog.csdn.net/s1hjf/article/details/128759758
https://blog.csdn.net/s1hjf/article/details/128756004
https://www.bilibili.com/video/BV1S5411X7FY

Guess you like

Origin blog.csdn.net/m0_48609250/article/details/129402319