温馨提示×

centos怎么查看pytorch版本

小樊
76
2026-09-18 13:01:38
栏目: 智能运维

在 CentOS 上查看 PyTorch 版本,常用方法如下:

方法一:通过 Python 命令查看(最常用)

python -c "import torch; print(torch.__version__)"

如果你用的是 Python 3:

python3 -c "import torch; print(torch.__version__)"

方法二:进入 Python 交互环境查看

python

进入后输入:

import torch
print(torch.__version__)

退出按 Ctrl + D 或输入 exit()

方法三:使用 pip 查看

pip show torch

或

pip3 show torch

方法四:使用 conda(如果你用 conda 安装的)

conda list torch

补充:查看 CUDA 是否可用及版本

import torch
print(torch.__version__)
print(torch.cuda.is_available())
print(torch.version.cuda)

如果提示 No module named torch,说明当前环境没有安装 PyTorch。

0 踩