How to find the current version of Pytorch


PyTorch is a Python library developed by engineers at Facebook in 2016 and is used to implement deep learning algorithms like natural language processing and image recognition.

Note: To learn more about PyTorch visit this link.

We can find the PyTorch version using the following ways.

Method 1: Python code

The following Python script is used to find the currently installed version of Pytorch:

import torch
print(torch.__version__)

In the code widget above, the first line imports the PyTorch library so that we can use its provided functionalities and methods.

The second line prints the version of PyTorch that is currently installed on the system using the torch.__version__ method.

Method 2: The pip command

If PyTorch is installed using pip, we can check its version by entering the following command into the terminal:

pip show torch

If we get an error "pip: command not found", we can use the alternative command mentioned below. This error can occur as we may have python3 installed instead of python2, which uses pip3 instead of the traditional pip command.

pip3 show torch

Let's click on the following terminal and get an idea of how the output looks like if we run pip show torch command.

Terminal 1
Terminal
Loading...

Method 3: Using the Conda command

If we install PyTorch using Anaconda Navigator, we can use the following command to check the PyTorch version.

conda list -f pytorch

Conclusion

To solve compatibility issues, we must know the current version of Pytorch running on our system. These methods can help us make informed decisions on properly incorporating the Pytorch library in our machine learning projects.

Free Resources

Copyright ©2025 Educative, Inc. All rights reserved