修改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")
相关推荐
爱看书的小沐9 天前
【小沐学AI】Python实现语音识别(whisper+HuggingFace)
人工智能·python·ai·nlp·whisper·语音识别·huggingface
我就是全世界12 天前
HuggingFace CLI 命令全面指南
python·huggingface
AI_小站16 天前
hugging face:大模型时代的github介绍
人工智能·科技·github·大语言模型·huggingface·ai大模型·计算机技术
Learning改变世界18 天前
Huggingface-cli 登录最新版(2024)
huggingface
shao9185161 个月前
Hugging Face系列2:详细剖析Hugging Face网站资源——实战六类开源库
huggingface·transformers·optimum·diffusers·peft·开源库·accelerate
Learning改变世界1 个月前
How to install a dataset from huggingface?
huggingface
HuggingFace2 个月前
Hugging Face 与 Wiz Research 合作提高人工智能安全性
huggingface·hugging face
G果2 个月前
申请 meta llama 模型权重(超详细)
python·meta·github·llama·权重·huggingface
SCBAiotAigc2 个月前
python代码无法点击进入,如何破???
人工智能·python·huggingface
镰刀韭菜2 个月前
【NLP】大语言模型基础之GPT
gpt·语言模型·自然语言处理·gpt4·huggingface·无监督预训练·有监督下游任务微调