Solution to the problem that torch.cuda.is_available() returns False after installing pytorch

After installing pytorch this year, only the CPU version can be installed, and the GPU cannot be used.

Refer to the method of this blog: The metaphysical method that perfectly solves the problem of torch.cuda.is_available() always returning False (The perfect solution of torch.cuda.is_available() always returns False The metaphysical method_python_Script Home (jb51.net))

Because I added the Tsinghua source image, when using conda to download, I will directly select Tsinghua source to download. Later, I checked the Tsinghua source website. It may be that Tsinghua source does not have a corresponding CUDA version of pytorch, so the CPU version will be installed.

Check the installed version on the Tsinghuayuan website (I installed cuda 11.3, and the installed pytroch version is 1.12.1)

 Later I found out that I installed python 3.8 version in the conda virtual environment.

After deleting the environment again

conda remove -n pytorch --all

Re-create the environment and install python version 3.10:

conda create -n pytorch python=3.10

After the installation is complete, follow the installation instructions on the pytorch official website

Finally, test torch.cuda.is_available() to return True, and you're done!​ 

 

Guess you like

Origin blog.csdn.net/zlbbme/article/details/126232042