是这样的,因为要下载可以用gpu的pytorch,用的pycharm下载,一直尝试
(D-learning) PS D:\pytorch_whl> pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu124
不限于关防火墙,用conda,翻墙,用清华源,改文件等等,下载是可以下载,但是速度极其慢,网速达到1m/s,但是一在pycharm里面下载就260kb/s,特别慢而且网速不稳定还会中间断开,b溃。
最后的解决办法是,直接在
1. 去 PyTorch 官方 whl
下载页面 : 🔗 https://download.pytorch.org/whl/cu121
https://download.pytorch.org/whl/cu121/
找到torch,点进去找到你的版本。
(上面是我的版本,如果你想下cuda12.4的或者其他版本改一下后缀)
找到 适合你的 Python 版本和操作系统的 .whl
文件,例如:
- Windows + Python 3.10:
torch-2.4.0+cu121-cp310-cp310-win_amd64.whl(只需要下载这个就可以)
torchvision-0.19.0+cu121-cp310-cp310-win_amd64.whl
torchaudio-2.4.0-cp310-cp310-win_amd64.whl
下载后,将 .whl
文件放入同一个文件夹 (比如 D:\pytorch_whl\
)
这三个
.whl
文件的作用分别是:
torch-2.4.0+cu121-cp310-cp310-win_amd64.whl
核心 PyTorch 库,必须安装!torchvision-0.19.0+cu121-cp310-cp310-win_amd64.whl
用于计算机视觉(CV)任务,比如图像处理、预训练模型等。如果你不做 CV 任务,可以不装。torchaudio-2.4.0-cp310-cp310-win_amd64.whl
用于音频处理,比如 ASR(语音识别)等。如果你不做音频任务,可以不装。
2. 手动安装 PyTorch
1️⃣ 打开 CMD 或 PowerShell,或者pycharm终端,切换到 .whl
文件所在目录:
cd D:\pytorch_whl\
2️⃣ 安装 PyTorch:
pip install torch-2.4.0+cu121-cp310-cp310-win_amd64.whl
pip install torchvision-0.19.0+cu121-cp310-cp310-win_amd64.whl
pip install torchaudio-2.4.0-cp310-cp310-win_amd64.whl
注意:
cp310
代表 Python 3.10 ,如果你的 Python 版本不同,请下载对应的.whl
文件!win_amd64
代表 Windows 64 位 ,如果你是 Linux,文件名会是manylinux_x86_64.whl
。
3. 安装 PyTorch 依赖
在 PyTorch 官方下载的 .whl
文件 中,已经包含了 核心 CUDA 依赖,但有些 Python 包需要手动安装。
🔹 常见依赖包 (可直接用 pip
安装):
pip install numpy filelock requests packaging pillow tqdm typing-extensions(直接复制粘贴进终端)
如果你要用 torch-tensorrt
(加速推理)
pip install torch-tensorrt
如果你要用 torchserve
(模型部署):
pip install torchserve torch-model-archiver
4. 验证 PyTorch 是否安装成功
运行
import torch
print(torch.version) # 应该输出 2.4.0
print(torch.cuda.is_available()) # 如果是 True,说明 CUDA 可用
如果 torch.cuda.is_available()
输出 False
:
可能 CUDA 版本不匹配 ,检查 torch.version.cuda
:
print(torch.version.cuda) # 应该输出 12.1
确保安装了 NVIDIA 驱动和 CUDA 12.1。




另外我还有些问题想问:
为什么我的网速很快,都是pycharm下载东西特别慢,不管是否开了镜像都很慢。
另外为什么我一翻墙想用vpn下载,别人用vpn会更快,但是我就会出现以下这种情况,SSLerror问题。有没有遇到过相同问题的友友,是怎么解决的?