问题描述:
使用浏览器访问 huggingface.co
网站正常,但通过 API 访问时出现 443 网络超时异常。
异常错误信息:
Downloading model failed with the following Hugging Face Hub error:
(MaxRetryError("HTTPSConnectionPool(host='huggingface.co', port=443): Max retries exceeded with url: /api/models/instructlab/granite-7b-lab-GGUF/tree/main?recursive=True&expand=False (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7f6f209a12d0>: Failed to establish a new connection: [Errno 101] Network is unreachable'))"), '(Request ID: 53cef903-5fa0-4d41-9798-8d2262aa1d4b)')Downloading model failed with the following error: 1
解决方案:
将 https://huggingface.co
网站修改为国内镜像网站 https://hf-mirror.com
,具体步骤如下:
1.进行全文搜索 huggingface_hub
,并执行相应搜索命令。
sudo find -name huggingface_hub
2.进入到huggingface_hub目录
3.修改 huggingface_hub
目录下的 constants.py
文件,把其中的 https://huggingface.co
替换为 https://hf-mirror.com
。
通过以上步骤,可以解决通过 API 访问 huggingface.co
网站时出现的 443 网络超时异常问题。同时,建议在操作前备份原始文件,以防止出现意外情况时可以恢复到初始状态。