---
title: 安装与验证
description: "1. 安装PyTorch 2.11.0 CUDA版本。"
url: https://www.hikunpeng.com/document/detail/zh/kunpengai/ecosystemEnable/pytorch/kunpengpytorch_04_0005.html
sourcePath: /source/zh/kunpengai/ecosystemEnable/pytorch/kunpengpytorch_04_0005.html
indexId: 1a3cedf7d5d48a0eaad0670570263f4e1d9ef81e134448e0244db7d8d6e9b59572
---
# 安装与验证

1. 安装PyTorch 2.11.0 CUDA版本。
  1 2 python3 -m pip install --upgrade pip setuptools wheel python3 -m pip install --index-url https://download.pytorch.org/whl/cu130 torch==2.11.0+cu130

2. 验证PyTorch是否安装成功。
  1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 python3 - <<'PY' import torch print("torch_version=" + torch.__version__) print("cuda_built=" + str(torch.backends.cuda.is_built())) print("torch_cuda_version=" + str(torch.version.cuda)) print("cuda_available=" + str(torch.cuda.is_available())) assert torch.backends.cuda.is_built() assert str(torch.version.cuda).startswith("13.0") assert torch.cuda.is_available() x = torch.tensor([[1.0, 2.0], [3.0, 4.0]]) y = torch.tensor([[5.0, 6.0], [7.0, 8.0]]) print("gpu_matmul=" + str((x.cuda() @ y.cuda()).cpu().tolist())) PY

  预期输出如下信息则安装成功。 1 2 3 4 5 torch_version=2.11.0+cu130 cuda_built=True torch_cuda_version=13.0 cuda_available=True gpu_matmul=[[19.0, 22.0], [43.0, 50.0]]
