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
Linuxexport 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
運行
Pythonimport 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