修改huggingface 的cache缓存路径

使用hugging face 来跑代码时,往往会把模型缓存到系统目录下,比如我的ubuntu系统就缓存到~.cache目录下。由于自己的home空间不足,先需要修改缓存的 .cache目录,修改方法如下:

找到自己安装的huggingface_hub下的constants.py 文件,比如我的文件位置在 lib/python3.10/site-packages/huggingface_hub 下。然后修改constants.py代码:

python 复制代码
# default cache
default_home = os.path.join(os.path.expanduser("~"), ".cache")
HF_HOME = os.path.expanduser(
    os.getenv(
        "HF_HOME",
        os.path.join(os.getenv("XDG_CACHE_HOME", default_home), "huggingface"),
    )
)
hf_cache_home = HF_HOME  # for backward compatibility. TODO: remove this in 1.0.0

把 default_home 修改为自己需要保存的文件路径即可。

我这里修改为:

python 复制代码
# default cache
default_home = os.path.join(os.path.expanduser("/root/autodl-tmp"), ".cache")
相关推荐
verse_armour5 天前
【深度学习】Grand Challenge、zenodo、huggingface数据集下载
人工智能·深度学习·huggingface·zenodo·数据集下载
腾飞开源7 天前
40_Spring AI 干货笔记之 Transformers (ONNX) 嵌入
人工智能·huggingface·onnx·transformers·嵌入模型·spring ai·句子转换器
leo030814 天前
【LLM微调】拒绝“假装聪明”:SFTTrainer 中 completion_only_loss 新旧版本用法详解
llm·sft·huggingface·trl
leo030814 天前
Hugging Face多卡训练“假快”?一文讲透`per_device_train_batch_size`的“陷阱”
llm·dp·huggingface·ddp
zhjadsf1 个月前
Huggingface_hub源码解析 - 简介篇
python·huggingface
计算衎1 个月前
python的AI大模型之facebook/nllb-200-distilled-600M的介绍和使用
人工智能·python·facebook·huggingface_hub
墨理学AI3 个月前
Linux 软连接 - 移动 huggingface 模型文件
huggingface·linux 软连接·hugging 模型复制
shizidushu3 个月前
Hugging Face NLP课程学习记录 - 3. 微调一个预训练模型
人工智能·学习·自然语言处理·微调·huggingface
HuggingFace5 个月前
Hugging Face 开源 HopeJR 机器臂!今日直播带你深入技术核心
开源·机械臂·huggingface