1. The installation of anoconda
1.1 download
anoconda is free software, install it directly through the official website
of anoconda official website
1.2 open
The downloaded software mainly includes these five, the main ones we need are anaconda prompt, jupyter notebook, spyder
2.pytorch installation
2.1 python environment configuration
The reason for using anoconda is because we may need python versions in different environments when we are doing projects, sometimes we need version 2.0, and some need version 3.0, so we need to build different environments here, when we need different to use.
Open the anoconda prompt and display base, which is the basic environment
through the command, where pytorch represents the naming of our environment
conda create -n pytorch python=3.7
After that, the environment will be downloaded automatically, and after downloading, enter the environment through the command
conda activate pytorch
2.2 pytorch environment installation
Check your own cuda version in cmd, through the command
nvidia-smi
Then open the pytorch official website to query the installation command pytorch official website
and select the corresponding version. The higher version is generally compatible with the lower version. Here, 11.7 is installed without cuda11.8.
Downloading is time consuming. It can be installed faster by using the Tsinghua mirror (not shown here)
The interface after downloading
2.3 Detect whether gpu is available
Enter the python environment to test whether the gpu is available
python
Enter the code to see if the gpu is available
import torch
torch.cuda.is_available()
Return true means the installation is successful
3. Problems encountered
3.1 torch.cuda.is_available() returns false
The possibility of encountering this problem is particularly high, but this installation was successful once. I encountered this problem before, and many methods have no effect. You can read this post and refer to this post.
Solve the problem that torch.cuda.is_available() returns False (use pip to install successfully)