huggingface加速

方法一:huggingface-cli

huggingface-cli是Hugging Face官方提供的命令行工具,自带完善的下载功能。

  1. 安装依赖
bash 复制代码
pip install -U huggingface_hub
  1. 设置环境变量: Linux
bash 复制代码
export HF_ENDPOINT=https://hf-mirror.com

建议将上面这一行写入~/.bashrc 。

3.1 下载模型

bash 复制代码
huggingface-cli download --resume-download gpt2 --local-dir gpt2

3.2 下载数据集

huggingface-cli download --repo-type dataset --resume-download wikitext --local-dir wikitext

可以添加 --local-dir-use-symlinks False 参数禁用文件软链接,这样下载路径下所见即所得,语句中gpt2和wikitext为模型名和数据集名称根据需要可替换。
方法二:使用hfd

  1. 下载hfd
bash 复制代码
wget https://hf-mirror.com/hfd/hfd.sh && chmod a+x hfd.sh
  1. 设置环境变量: Linux
bash 复制代码
export HF_ENDPOINT=https://hf-mirror.com

3.1 下载模型

bash 复制代码
./hfd.sh gpt2 --tool aria2c-x4

3.2 下载数据集

bash 复制代码
./hfd.sh wikitext --dataset --tool aria2c -x4

语句中gpt2和wikitext为模型名和数据集名称根据需要可替换,aria2c为预装工具,安装口令:'apt update && apt install aria2'

部分 Gated Repo 问题

部分Gated Repo需登陆申请许可。前往Hugging Face获取AccessToken后使用命令行下载。

部分工具下载Gated Repo的方法:

huggingface-cli:添加--token 参数

huggingface-cli download --token hf_*** --resume-download meta-llama/Llama-2-7b-hf --local-dir Llama-2-7b-hf

hfd: 添加--hf_username --hf_token 参数

hfd meta-llama/Llama-2-7b --hf_username YOUR_HF_USERNAME --hf_token hf_***

注:容器内下载存在限速,下载大数据集或大模型时,建议本地下载后再使用SFTP上传

相关推荐
云泽野2 小时前
【Java|集合类】list遍历的6种方式
java·python·list
IMPYLH3 小时前
Python 的内置函数 reversed
笔记·python
小赖同学啊5 小时前
物联网数据安全区块链服务
开发语言·python·区块链
码荼6 小时前
学习开发之hashmap
java·python·学习·哈希算法·个人开发·小白学开发·不花钱不花时间crud
小陈phd7 小时前
李宏毅机器学习笔记——梯度下降法
人工智能·python·机器学习
kk爱闹7 小时前
【挑战14天学完python和pytorch】- day01
android·pytorch·python
Blossom.1187 小时前
机器学习在智能建筑中的应用:能源管理与环境优化
人工智能·python·深度学习·神经网络·机器学习·机器人·sklearn
亚力山大抵7 小时前
实验六-使用PyMySQL数据存储的Flask登录系统-实验七-集成Flask-SocketIO的实时通信系统
后端·python·flask
showyoui7 小时前
Python 闭包(Closure)实战总结
开发语言·python
amazinging8 小时前
北京-4年功能测试2年空窗-报培训班学测开-第四十一天
python·学习·appium