Pytorch is a machine learning framework that allows you to build applications on computer vision and NLP ( Natural Language Processing ). It is open source and freely available to use among developers. In this article, you will know how to check the version of PyTorch in Jupyter, Colab, Terminal, Anaconda, and Pycharm.
How to check the version of PyTorch
Let’s know the methods to find which version of PyTorch you are using on all the platforms if you have installed Pytorch in your system.
Please note that if the torch module is not installed and your try to import it then you will get the error No module named ‘torch’ modulenotfounderror. So before checking the version make sure it is installed or not.
If you are using Jupyter Notebook and already installed the Pytorch, then the best way to check is to open the notebook and type the following command in a cell:
!pip show torch
It will print out the version of PyTorch that is installed in your system.
In Google Colaboratory, you can get the version of PyTorch by executing the following code in a cell.
!pip show torch
!pip freeze | grep torch
You will get the version of the PyTorch in the colab.
Terminal or Command Prompt
If you are using a terminal or the command prompt then, you can check the version of PyTorch by running the following command:
pip show torch
Here you don’t have to put the “!” before the pip command like the above platforms,
You will get the version of the PyTorch in the output.
Anaconda or Conda
In Anaconda, you can check the PyTorch by executing the following command in the Anaconda Prompt.
conda list torch
It will list out the PyTorch with the version installed in your system.
If you are using PyTorch on Pycharm, you can check the version by Navigating to the file. Go to File > Settings > Project Interpreter. It will open the Project Interpreter window. There you will see the list of all the installed packages in your working project. You will know the version of PyTorch next to the package name.
Pytorch is widely used by developers for making predictive models. If you have installed the Pytorch module in your system then these are the ways to check its version in Jupyter, Colab, the Terminal, Anaconda, and Pycharm.