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上传

相关推荐
invicinble3 小时前
这里对java的知识体系做一个全域的介绍
java·开发语言·python
m0_674294644 小时前
如何编写SQL存储过程性能对比_记录执行时间评估优化效果
jvm·数据库·python
运气好好的4 小时前
怎样开启phpMyAdmin的操作审计日志_记录每条执行的SQL
jvm·数据库·python
2401_871492855 小时前
Layui如何修改Layui默认的UI主题颜色(换肤功能实现)
jvm·数据库·python
南子北游6 小时前
Python学习(基础语法1)
开发语言·python·学习
步辞6 小时前
Redis如何利用LFU算法优化缓存命中率
jvm·数据库·python
forEverPlume6 小时前
golang如何实现日志按级别过滤_golang日志按级别过滤实现教程
jvm·数据库·python
m0_624578598 小时前
MySQL主从复制支持跨版本吗_不同版本间同步的注意事项
jvm·数据库·python
yuanpan8 小时前
Python Pygame 入门教程:从零学会创建窗口、绘图和游戏交互
python·游戏·pygame
2401_871492858 小时前
如何在 React Router v6 中正确配置多路由组件显示
jvm·数据库·python