【AI模型部署】
解决python引入huggingface_hub模块下载超时问题
- 背景
- 问题
- 解决
背景
AMD Ryzen™ AI处理器通过独特的NPU+GPU异构架构,为AI工作负载提供强大的并行计算能力。本方案展示了如何将YOLOv8目标检测、RCAN超分辨率重建和Stable Diffusion文生图三类模型分别部署到NPU和GPU,实现计算资源的智能调度。
问题
本地部署模型时,py代码中引入huggingface_hub模块并执行时,报下载超时。
from huggingface_hub import model_info
raise ConnectTimeout(e, request=request)
requests.exceptions.ConnectTimeout: (MaxRetryError("HTTPSConnectionPool(host='huggingface.co', port=443): Max retries exceeded with url: /api/models/runwayml/stable-diffusion-v1-5 (Caused by ConnectTimeoutError(<urllib3.connection.HTTPSConnection object at 0x00000222DC116050>, 'Connection to huggingface.co timed out. (connect timeout=None)'))"), '(Request ID: d0ef776a-1cf6-4c07-a260-908d1684f2ae)')
解决
- 在当前python虚拟环境终端下执行:
pip show huggingface_hub | findstr Location
- 找到huggingface_hub包,并打开:
- 找到constants.py文件,并修改:将huggingface.co全部替换为hf-mirror.com即可。