目录
2026.05国内替代下载方法:
官网:https://huggingface.co/
202610最新下载命令
windows系统下载 测试ok:
python下载方法:
~/.bashrc
缓存目录,默认模型下载目录
设置缓存目录:
git下载方法
python版安装方法:
2026下载新命令:
python 下载无token 2026测试ok:
然后命令行下载:
python 下载带token
python下载不带token:
常见报错
登录后创建Read token
2.3 创建token
使用token登录
2026.05国内替代下载方法:
pip install atomgit
atomgit download hf_mirrors/briaai/RMBG-2.0 -d ./
官网:https://huggingface.co/
202610最新下载命令
# 1. 清除所有可能冲突的代理环境变量 unset HTTP_PROXY HTTPS_PROXY ALL_PROXY http_proxy https_proxy all_proxy # 2. 设置使用国内镜像站 export HF_ENDPOINT=https://hf-mirror.com hf download EricRollei/HunyuanImage-3.0-Instruct-Distil-NF4-v2 --local-dir ./EricRollei_HunyuanImage-3.0-Instruct-Distil-NF4-v2windows系统下载 测试ok:
$env:HF_ENDPOINT = "https://hf-mirror.com" hf download microsoft/OmniParser-v2.0 --local-dir ./microsoft_OmniParser-v2python下载方法:
设置环境变量Linux
export HF_ENDPOINT=https://hf-mirror.com~/.bashrc
export HUGGINGFACE_HUB_CACHE=/mnt/xxx/huggingface/ export HF_DATASETS_CACHE=/xxx/huggingface/ export TRANSFORMERS_CACHE=/mnt/xxx/huggingface/ export TORCH_HOME=/mnt/pfs/models/torch/ export PIP_CACHE_DIR=/mnt/xxx/cache/ export HF_ENDPOINT=https://hf-mirror.com缓存目录,默认模型下载目录
~/.cache/huggingface
设置缓存目录:
export HF_HOME=/shared_disk/models/hug_cache
Python cam_pose/monst3r_v1/demo.py
Windows Powershell
$env:HF_ENDPOINT = "https://hf-mirror.com"git下载方法
- 安装lfs:git lfs install
克隆数据集仓库:
# 使用HTTPS方式克隆 git clone https://huggingface.co/datasets/agkphysics/AudioSet
python版安装方法:
pip install -U huggingface_hub
powershell
$env:HF_ENDPOINT = "https://hf-mirror.com"2026下载新命令:
huggingface-cli login
python -c "from huggingface_hub import login;login(token='xxx')"
export HF_ENDPOINT=https://hf-mirror.com hf download dle666/GeoFocus-7B --local-dir ./dle666_GeoFocus-7Bpython 下载无token 2026测试ok:
python -c "from huggingface_hub import login;login(token='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')"然后命令行下载:
# 1. 设置镜像站环境变量 set HF_ENDPOINT=https://hf-mirror.com # 2. 下载数据集(明确指定 repo_type="dataset") python -c "from huggingface_hub import snapshot_download; snapshot_download(repo_id='OpenGVLab/GMAI-MMBench', repo_type='dataset', local_dir='./GMAI-MMBench')"python 下载带token
import os os.environ["HF_ENDPOINT"] = "https://hf-mirror.com" from huggingface_hub import snapshot_download local_dir = r"B:\data\aigc1" repo_id = "black-forest-labs/FLUX.1-dev" token = "xxxxxx" snapshot_download(repo_id=repo_id, local_dir=local_dir, resume_download=True, local_dir_use_symlinks=False, token=token) # 没成功: # from huggingface_hub import hf_hub_download # hf_hub_download(repo_id="black-forest-labs/FLUX.1-dev" ,filename="model_index.json" ,local_dir="./qafacteval")python下载不带token:
from huggingface_hub import hf_hub_download flow_ckpt_path = hf_hub_download(repo_id="nvidia/PartPacker", filename="flow.pt")常见报错
- huggingface-cli: error: invalid choice: ‘download’ (choose from ‘env’, ‘login’, ‘whoami’, ‘logout’, ‘repo’, ‘lfs-enable-largefiles’, ‘lfs-multipart-upload’, ‘scan-cache’, ‘delete-cache’)
- 可能是由于python版本<3.8,下载的huggingface-cli版本过低;在python>=3.8环境下运行
pip install -U huggingface_hub命令后解决
- 可能是由于python版本<3.8,下载的huggingface-cli版本过低;在python>=3.8环境下运行
- ModuleNotFoundError: No module named ‘chardet’
- 安装对应模块即可:
pip install chardet
- 安装对应模块即可:
annot instantiate this tokenizer from a slow version. If it's based on sentencepiece, make sure you have sentencepiece installed.
解决方法:
pip install transformers[sentencepiece]
登录后创建Read token
在浏览器左边有个settings,里面有 ass
https://huggingface.co/settings/tokens
- 点击提交后,会有提示settings中会有消息。Settings页面如下图操作就可以找到。
Settings页面查找方式
2.3 创建token
- 当注册账号的邮箱收到邮件后,可以进入Settings页面,按照如下图操作。
Access token页面
- 点击【Create new token】后,最先遇到的就是token type的选择了。页面列举了三类,需要根据自己的使用场景进行选择。
创建新的token
三种Token类型的权限:
Fine-grained:
适用场景: 允许特定操作(如读取、写入或微调),则可以选择“Fine-grained”权限。这种类型适合需要精细管理访问权限的用户,特别是在团队协作或项目中。
Read:
适用场景: 如果您只需要访问模型进行推理或下载模型,而不打算进行任何修改或训练,选择“Read”权限即可。
Write:
适用场景: 如果您打算对模型进行修改、上传新的模型权重或更新现有模型,则需要选择“Write”权限。这通常适用于开发者或研究人员,他们需要将自己的工作成果上传到Hugging Face平台。
使用token登录
huggingface-cli login
会提示输入 token,鼠标右键后,回车。
然后提示输入y,没报错就可以下载了。