配置 huggingface 鏡像, git clone深度, 啟用加速下載包(rust實現(xiàn))
# huggingface
export HF_ENDPOINT="https://hf-mirror.com"
export GIT_LFS_SKIP_SMUDGE=1
export HF_HUB_ENABLE_HF_TRANSFER=1
下載工具包及加速下載包(啟用加速工具 hf-transfer 需要環(huán)境變量 HF_HUB_ENABLE_HF_TRANSFER 為 1)
pip install -U huggingface_hub
pip install -U hf-transfer
生成本地 token 文件
from huggingface_hub.hf_api import HfFolder
HfFolder.save_token('hf_your_token_string')
huggingface 會把token寫入到: ~/.cache/huggingface/token
import torch; print(torch.cuda.is_available())