修改huggingface 的cache缓存路径

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

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

# 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 修改为自己需要保存的文件路径即可。

我这里修改为:

# default cache
default_home = os.path.join(os.path.expanduser("/root/autodl-tmp"), ".cache")

相关推荐

  1. 修改huggingface cache缓存路径

    2024-04-09 07:56:03       36 阅读
  2. Teamcenter 修改缓存文件夹名称及路径方法

    2024-04-09 07:56:03       69 阅读
  3. Cache缓存

    2024-04-09 07:56:03       32 阅读
  4. Buffer(缓冲)、Cache缓存

    2024-04-09 07:56:03       62 阅读
  5. linux缓存page cache

    2024-04-09 07:56:03       56 阅读
  6. 使用nginxproxy_cache实现静态资源缓存

    2024-04-09 07:56:03       56 阅读
  7. SpringBoot Cache缓存

    2024-04-09 07:56:03       53 阅读
  8. Shiro-12-caching 缓存

    2024-04-09 07:56:03       63 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-04-09 07:56:03       94 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-04-09 07:56:03       100 阅读
  3. 在Django里面运行非项目文件

    2024-04-09 07:56:03       82 阅读
  4. Python语言-面向对象

    2024-04-09 07:56:03       91 阅读

热门阅读

  1. django怎么设置把logger.info的日志保存到本地文件

    2024-04-09 07:56:03       37 阅读
  2. Matlab之R2024a安装软件分享

    2024-04-09 07:56:03       42 阅读
  3. MySQL调优时需要注意的问题

    2024-04-09 07:56:03       40 阅读
  4. Spring、SpringMVC、Springboot三者的区别和联系

    2024-04-09 07:56:03       45 阅读
  5. 从输入URL到页面渲染的全过程详解

    2024-04-09 07:56:03       38 阅读
  6. 链表实现学生管理系统

    2024-04-09 07:56:03       41 阅读