深度阅读

How to check which PyTorch version is installed?

作者
作者
2023年08月22日
更新时间
8.07 分钟
阅读时间
0
阅读量

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.

相关标签

博客作者

热爱技术,乐于分享,持续学习。专注于Web开发、系统架构设计和人工智能领域。