Problem Description
In the process of installing pytorch, I found that the result of the final verification of torch was always False, but I turned it up and found that I installed the cpu version.
Then try to change different versions through conda, and found that they are all cpu versions.
problem analysis
Installing pytorch through conda is to search for the files in the matching instructions from the source, but the source probably does not have the required cuda version of pytorch. As a result, each installation matches the cpu version that exists in the source as a substitute
problem solved
Finally decided to install via pip
1. First check the cuda version supported by your device, open the prompt, and enter the command
nvidia-smi
You can see that the highest version supported by my device is cuda11.4, which is generally backward compatible. Here I choose to install a full set of cuda11.3 and the corresponding pytorch
2. Install cuda and cudnn (omitted)
Download it from the official website here, and install it step by step. After the cuda installation is complete, unzip cudnn and copy the three folders inside to the cuda directory.
3. Configure the environment variables of cuda (omitted)
It can be configured in the local environment variable.
4. Prompt to install pytorch
First activate the environment you want to use, if not, create it first, try not to operate under the base, enter the command
conda activate freezing
It turned out to be the base environment. After entering the command, it was successfully activated and switched to the freezing environment.
5. Go to the official website of pytorch to check the instructions of the corresponding version
The selected one is the command to be entered.
pip3 install torch==1.10.2+cu113 torchvision==0.11.3+cu113 torchaudio===0.10.2+cu113 -f
https://download.pytorch.org/whl/cu113/torch_stable.html
Then wait for the installation
6. Verify whether the installation is successful
Enter the command and enter python
python
Then enter
import torch
torch.cuda.is_available()
Verification returns True to be successful