In this article, we will show how to check which version of PyTorch is installed in the IDE.
How to Check PyTorch Version?
The first public release of PyTorch, “version 0.1.0”, was announced in January 2017 by Adam Pasczke and his team. “Version 1.0” was the first steppingstone in the history of PyTorch and it was opened to the public in October 2018. Fast forward to the present, “version 2.0” was released in March 2023.
Knowing the version of PyTorch installed in the IDE can help to affirm that the specific features required for a particular project are available and resolve code compatibility issues.
Follow the steps below to check the installed version of PyTorch.
Step 1: Launch Google Colab
Open Google Colab and begin a new notebook as shown below:
Step 2: Install Required Libraries
Use the “pip” package installer from Python to install the “Torch” and “Torchvision” libraries:
“Torch” and “Torchvision” are the fundamental libraries that contain all the functionalities of the PyTorch framework:
Step 3: Import the Installed Libraries
Use the “import” module to import the installed libraries “Torch” and “Torchvision” into the project:
import torchvision
Step 4: Check PyTorch Version
Now, use the installed “Torch” library as the object to call the “__version__” attribute to access the Pytorch version and print the version using the “print()” method:
The below output indicates that we have accessed the PyTorch version:
Note: You can access our Google Colab Notebook for yourself from this link.
Pro-Tip:
There are numerous benefits to knowing which version of PyTorch is installed in IDE. It can help avoid any issues of compatibility in the code when a large team is working on the same project. Moreover, bugs and errors can be easily removed by comparing the performance of different versions.
Conclusion
To check the PyTorch version installed in the IDE, install and import the “Torch” library first into your program. After that, use the imported “torch” library along with the “__version__” attribute and pass it as the argument of the “print()” method to check and display the Pytorch version. This blog has explained how to check the Pytorch version.