加速 PyTorch(CUDA 12.7) 下载安装记录(自用)

0 阅读1分钟

加速 PyTorch(CUDA 12.7) 下载安装记录(自用)

基本信息:

  1. 系统版本:Windows 11 家庭中文版
  2. 系统版本号:25H2
  3. 文章内容更新:日期2026.3.1;时间9:37:15
  4. 下载版本:PyTorch(CUDA 12.7)
  5. 当前已完成工作:

安装配置 Anaconda3-2022.05

下载安装

  1. 打开 NVIDIA 控制面板 → 系统信息 → 组件 ,检查 NVIDIA CUDA 版本号为 12.7

image.png

  1. 访问 PyTorch 官网:pytorch.org/get-started… ,选择对应 CUDA 版本的 PyTorch:

image.png

  1. 把官网生成的命令给豆包,要一个清华镜像下载的命令(更快),在 Anaconda Prompt(已激活 cabin-env)中粘贴运行。
pip install torch torchvision torchaudio -i https://pypi.tuna.tsinghua.edu.cn/simple --extra-index-url https://download.pytorch.org/whl/cu126

或者直接用官网生成的命令

pip3 install torch torchvision --index-url https://download.pytorch.org/whl/cu126

验证

安装完成后,在终端里逐行输入以下代码,依次回车:

  1. 进入 Python 交互环境
python

2. 导入PyTorch

import torch

3. 查看 PyTorch 版本

print("PyTorch版本:", torch.__version__)

4. 核心验证:CUDA是否可用(输出True就是GPU版安装成功)

print("CUDA是否可用:", torch.cuda.is_available())

5. 查看识别到的显卡型号

print("显卡型号:", torch.cuda.get_device_name(0))

6. 退出退出Python交互模式

exit()

后续训练模型会自动调用显卡加速,速度比 CPU 快 10 倍以上。