无法下载安装PyTorch求助:使用Automatic1111时遇超时错误
PyTorch下载超时问题解决指南
问题详情
为Automatic1111安装PyTorch时遭遇下载超时错误,使用的安装命令如下:
python -m pip --default-timeout=600 install torch==1.13.1+cu117 torchvision==0.14.1+cu117 --extra-index-url https://download.pytorch.org/whl/cu117 --no-cache-dir
已确认Python版本为3.10.6(通过py -0p命令验证),尝试过以下方法但未解决:
- 更新pip版本
- 直接下载PyTorch wheel包进行本地安装
- 将Python安装目录从用户文件夹迁移至ProgramFiles目录
错误核心提示:
pip._vendor.urllib3.exceptions.ReadTimeoutError: HTTPSConnectionPool(host='download.pytorch.org', port=443): Read timed out.
有效解决方案
1. 延长超时阈值
将pip的默认超时时间进一步调高,比如设置为1200秒(20分钟),给大文件足够的下载时间:
python -m pip --default-timeout=1200 install torch==1.13.1+cu117 torchvision==0.14.1+cu117 --extra-index-url https://download.pytorch.org/whl/cu117 --no-cache-dir
2. 切换国内镜像源加速
使用国内镜像替代官方源,大幅提升下载速度,避免超时:
清华镜像示例命令:
python -m pip --default-timeout=1200 install torch==1.13.1+cu117 torchvision==0.14.1+cu117 --extra-index-url https://mirrors.tuna.tsinghua.edu.cn/pytorch-wheels/cu117/ --no-cache-dir
3. 分步骤单独安装
拆分torch和torchvision的安装过程,避免同时下载大文件导致的网络负载过高:
- 先安装torch:
python -m pip --default-timeout=1200 install torch==1.13.1+cu117 --extra-index-url https://download.pytorch.org/whl/cu117 --no-cache-dir
- 再安装torchvision:
python -m pip --default-timeout=1200 install torchvision==0.14.1+cu117 --extra-index-url https://download.pytorch.org/whl/cu117 --no-cache-dir
4. 排查网络环境问题
- 关闭代理、VPN工具,部分代理会干扰PyTorch官方源的连接稳定性
- 切换至有线网络,避免无线网络信号波动导致的中断
- 临时关闭防火墙或杀毒软件,防止其误拦截下载请求
内容的提问来源于stack exchange,提问作者Ofentse Nglazi
相关产品推荐
相关产品推荐

