温馨提示×

centos怎么查看pytorch

小樊
89
2026-09-09 10:39:45
栏目: 智能运维

在 CentOS 上查看 PyTorch 是否安装以及版本信息,一般按下面几种方式来:


一、查看 PyTorch 是否安装 & 版本

1️⃣ 使用 pip 安装的 PyTorch

pip show torch

或

pip3 show torch

输出示例:

Name: torch
Version: 2.1.0

2️⃣ 使用 conda 安装的 PyTorch

conda list torch

二、在 Python 中查看 PyTorch

python

或

python3

然后输入:

import torch
print(torch.__version__)

查看 CUDA 是否可用:

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

三、查看 PyTorch 安装路径

import torch
print(torch.__file__)

四、查看系统 CUDA / cuDNN(可选)

查看 CUDA 版本

nvcc --version

或

cat /usr/local/cuda/version.txt

查看 cuDNN 版本

cat /usr/local/cuda/include/cudnn_version.h | grep CUDNN_MAJOR -A 2

五、常见问题

✅ import torch 报错

  • 可能是 Python 版本不对应
  • 可能是 PyTorch 没装到当前 Python 环境

✅ 多个 Python 环境 先用:

which python
which pip

确认环境一致


如果你愿意,可以告诉我:

  • CentOS 版本(7 / 8 / Stream)
  • 是否用 conda / 虚拟环境
  • 是否有 GPU

我可以给你更精确的命令 ✅

0 踩