在服务器上,通过sh文件运行vLLM服务时,报错连不上HuggingFace:
OSError: We couldn't connect to 'https://huggingface.co' to load this file, couldn't find it in the cached files and it looks like THUDM/chatglm2-6b is not the path to a directory containing a file named configuration_chatglm.py.
Checkout your internet connection or see how to run the library in offline mode at 'https://huggingface.co/docs/transformers/installation#offline-mode'.
因为是实验室服务器,连不上HF是很正常的,我们用国内的菩萨网站 hf-mirror.com 就能解决这个问题:

先安装 huggingface_hub,这是 Hugging Face 官方提供的命令行工具,自带完善的下载功能:
pip install -U huggingface_hub
然后在命令行设置环境变量,因为是临时性下载,我就没有把环境变量保存到.bashrc文件:
export HF_ENDPOINT=https://hf-mirror.com
把HF_HUB_OFFLINE设置为0,表示从网上下载模型,如果为1,则表示从本地加载模型:
export HF_HUB_OFFLINE=0
我们打印一下看是不是正确的路径:
echo $HF_ENDPOINT
echo $HF_HUB_OFFLINE
这个时候我们就可以从hf-mirror下载模型了,第一个THUDM/chatglm2-6b是hf-mirror的模型路径,第二个THUDM/chatglm2-6b是保存到的本地路径:
huggingface-cli download --resume-download THUDM/chatglm2-6b --local-dir THUDM/chatglm2-6b
此时就开始下载了:

等待完成后,我们可以到默认的.catch文件夹中查看下载的模型:
路径是:用户名/.cache/huggingface/hub
这样,我们就可以绕过防火墙的限制,下载HuggingFace上的模型了?。

推荐本站淘宝优惠价购买喜欢的宝贝:
本文链接:https://hqyman.cn/post/9409.html 非本站原创文章欢迎转载,原创文章需保留本站地址!
打赏

微信支付宝扫一扫,打赏作者吧~
休息一下~~