How to check which PyTorch version is installed?
Published on Aug. 22, 2023, 12:18 p.m.
To check which version of PyTorch is installed, you can use the __version__
attribute of the torch
module. Here’s an example:
import torch
print(torch.__version__)
Output:
1.9.0
In the example above, torch.__version__
returns the version number of PyTorch that is currently installed.
Alternatively, you can also use the command pip show torch
in the command line to see the version number of PyTorch that is installed using pip.
pip show torch
Output:
Name: torch
Version: 1.9.0
Summary: Tensors and Dynamic neural networks in Python with strong GPU acceleration
...
In summary, to check which version of PyTorch is installed, use either the __version__
attribute of the torch
module, or use the command pip show torch
in the command line.