install
sudo dpkg -i gh_2.74.0_linux_amd64.deb
gh auth login
gh auth login
? Where do you use GitHub? GitHub.com
? What is your preferred protocol for Git operations on this host? HTTPS
? Authenticate Git with your GitHub credentials? Yes
? How would you like to authenticate GitHub CLI? Paste an authentication token
Tip: you can generate a Personal Access Token here https://github.com/settings/tokens
The minimum required scopes are 'repo', 'read:org', 'workflow'.
? Paste your authentication token: *********************************************************************************************
- gh config set -h github.com git_protocol https
✓ Configured git protocol
✓ Logged in as HenryZhangJianhe
gh release list -R NVlabs/OmniDrive
gh release download v1.0 -D . -R NVlabs/OmniDrive
hugging face
use china mirror fast
git clone https://hf-mirror.com/exiawsh/pretrain_qformer
pip install -U huggingface_hub
export HF_ENDPOINT=https://hf-mirror.com
如果使用python
$env:HF_ENDPOINT = “https://hf-mirror.com”
huggingface-cli download --resume-download gpt2 --local-dir gpt2
huggingface-cli download --repo-type dataset --resume-download wikitext --local-dir wikitext
真实模型则存储在~/.cache/huggingface下,如果不喜欢这个可以用 --local-dir-use-symlinks False取消这个逻辑。
huggingface-cli download exiawsh/pretrain_qformer
方法三:使用 hfd (推荐)
hfd 是https://hf-mirror.com/开发的 huggingface 专用下载工具,基于成熟工具 git+aria2,可以做到稳定下载不断线。
1. 下载hfd
wget https://hf-mirror.com/hfd/hfd.sh
chmod a+x hfd.sh
AI写代码
python
运行
2. 设置环境变量
HF_ENDPOINT 该变量是 HF 相关库官方支持的一个环境变量,设置后,相关库会尊重该变量指定的主机名,替换 huggingface.co 域名进行模型、数据集的下载和上传,从而做到无需修改python的transformers代码,即可利用上镜像站来加载模型。具体支持以下库:
huggingface-cli
snapshot_download
from_pretrained
hf_hub_download
timm.create_model
Linux
export HF_ENDPOINT=https://hf-mirror.com
AI写代码
python
运行
Linux 写入到~/.bashrc中:
echo 'export HF_ENDPOINT="https://hf-mirror.com"' >> ~/.bashrc
AI写代码
python
运行
Windows Powershell
$env:HF_ENDPOINT = "https://hf-mirror.com"
AI写代码
python
运行
Python
import os
os.environ['HF_ENDPOINT'] = 'https://hf-mirror.com'
AI写代码
python
运行
3.1 下载模型(例子: gpt2)
./hfd.sh gpt2 --tool aria2c -x 4
AI写代码
python
运行
如果没有安装 aria2,则可以默认用 wget:
./hfd.sh gpt2
AI写代码
python
运行
3.2 下载数据集 (例子: wikitext )
./hfd.sh wikitext --dataset --tool aria2c -x 4
AI写代码
python
运行
方法四:使用环境变量(非侵入式)
非侵入式,能解决大部分情况。huggingface 工具链会获取HF_ENDPOINT环境变量来确定下载文件所用的网址,所以可以使用通过设置变量来解决。
HF_ENDPOINT=https://hf-mirror.com python your_script.py
AI写代码
python
运行
不过有些数据集有内置的下载脚本,那就需要手动改一下脚本内的地址来实现了。
————————————————
版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
原文链接:https://blog.csdn.net/weixin_40959890/article/details/140319652