1.设置 HF_ENDPOINT 环境变量
HF_ENDPOINT
该变量是 HF 相关库官方支持的一个环境变量,设置后,相关库会尊重该变量指定的主机名,替换 huggingface.co 域名进行模型、数据集的下载和上传,从而做到无需修改python的transformers代码,即可利用上镜像站来加载模型。具体支持以下库:
huggingface-cli
snapshot_download
from_pretrained
hf_hub_download
timm.create_model
Linux 写入到~/.bashrc
中:
echo 'export HF_ENDPOINT="https://hf-mirror.com"' >> ~/.bashrc
2.该网站提供了 hfd 工具,基于 aria2 开发,理论上能实现稳定高速下载不断线。按照网站说明下载 hfd 工具,先执行wget https://hf-mirror.com/hfd/hfd.sh
下载脚本,再通过sudo chmod a+x hfd.sh
赋予执行权限,设置环境变量export HF_ENDPOINT=https://hf-mirror.com
(Linux 系统,Windows 系统使用对应命令),之后用./hfd.sh
命令下载模型或数据集,相比其他方式,它的下载速度更快。
3.如果报错:aria2c is not installed. Please install it first.
使用 sudo apt install aria2安装相应库文件
4.假如要下载的是m-a-p/YuE-s1-7B-anneal-en-cot · HF MirrorWe’re on a journey to advance and democratize artificial intelligence through open source and open science.https://hf-mirror.com/m-a-p/YuE-s1-7B-anneal-en-cot则可以使用./hfd.sh m-a-p/YuE-s1-7B-anneal-en-cot完成相应模型的下载
.
.