1 What is Pytorch
Pytorch is a scientific computing package based on Python, similar to Numpy but capable of utilizing GPU acceleration. It is also a very flexible and fast research platform for deep learning.
2 Installing Pytorch
Check if Your Computer Has an NVIDIA Graphics Card
From a hardware perspective, NVIDIA has supported CUDA technology since the Geforce 9XXX series graphics cards, starting with the G92/G94/G96 cores. However, NVIDIA has optimized its drivers to ensure that all products from the Geforce 8XXX series onwards support CUDA general computing technology. This means that all products from the G80/G84/G86 cores onwards support CUDA technology.
Start the dx diagnostic tool during operation to check your graphics card model.
Confirm Your CUDA Version
Check the Installation Instructions Suitable for You on the Pytorch Official Website
Link: https://pytorch.org/get-started/locally/
Select the required version, operating platform, installation method, programming environment, and CUDA version.
Finally, copy the generated command and run it in cmd.
When asked whether to continue, enter y or yes, and then wait for a while.
Check if the Installation was Successful
Create a random file to try importing the package; if there are no errors, the installation is complete.
Check if CUDA is Available
Run the above code; if the console outputs True, then CUDA is available. If the GPU’s CUDA version is lower than the installed version, it will also cause the output to be False.
# The following are the commands and codes used in the articleconda install pytorch torchvision torchaudio cudatoolkit=11.6 -c pytorch -c conda-forgeimport torchprint(torch.cuda.is_available()) |
3 Conclusion
If you need CUDA acceleration, you must carefully confirm your CUDA version. A classmate and I have the same graphics card model, and both drivers are the latest, but my CUDA version is 11.7 while his is 11.2. Therefore, after following the same installation steps as mine, he could not use CUDA, and it took a long time to find out. If you need a higher version of CUDA, you can upgrade it on the official website.