9951 explained code solutions for 126 technologies


python-pytorchHow do I get the version of PyTorch I am using?


You can get the version of PyTorch you are using by running the torch.__version__ command.

import torch
print(torch.__version__)

Output example

1.6.0
  • import torch imports the PyTorch module
  • torch.__version__ is an attribute that stores the version of PyTorch
  • print(torch.__version__) prints the version of PyTorch

Helpful links

Edit this code on GitHub