# Cannot use Hugging Face cache on a read-only filesystem

**URL:** <https://discuss.huggingface.co/t/cannot-use-hugging-face-cache-on-a-read-only-filesystem/137622>\
**Category:** 🤗Transformers\
**Created:** [January 27, 2025, 10:19pm UTC](https://discuss.huggingface.co/t/cannot-use-hugging-face-cache-on-a-read-only-filesystem/137622 "2025-01-27T22:19:30Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![stodo](https://avatars.discourse-cdn.com/v4/letter/s/2bfe46/32.png) [@stodo](https://discuss.huggingface.co/u/stodo)\
**Post date:** [January 27, 2025, 10:19pm UTC](https://discuss.huggingface.co/t/cannot-use-hugging-face-cache-on-a-read-only-filesystem/137622/1 "2025-01-27T22:19:30Z")

</div>

Hello,

I’m having some trouble with getting the huggingface cache to work for my particular use case. I’ve been setting up kubernetes training for my transformer models, and the way it works is that pods are initialized from a docker image and then I mount a persistent disk with the data. Since pods are initialized from a docker image, any other files relevant for training (e.g. the training data) must be stored on the persistent disk. This disk is mounted in readonly mode due to certain limitations outside of my control.

Currently, downloading the model checkpoint for whichever architecture I wish to fine-tune eats up a lot of time, so I’d like to take advantage of the HF cache. The problem is that if I do so by downloading the models to a cache folder on the previously mentioned persistent disk, then setting the `HF_HOME` environment variable to point to that folder, my training runs will crash since huggingface tries to write to the `HF_HOME` folder for some reason. The model weights are already fully downloaded and have not been updated since, so I’m not really sure why this is the case. I realize that when running `AutoModel.from_pretrained` I could provide a local filepath instead of the pretrained model name, but then I’m basically managing the cache myself and I’m wondering if instead there is a setting for this.

In short, how can I use cached, already downloaded model weights from a readonly filesystem?

---

<div class="post-metadata">

**Author:** ![John6666](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/john6666/32/27664_2.png) [@John6666](https://discuss.huggingface.co/u/John6666)\
**Post date:** [January 28, 2025, 3:51am UTC](https://discuss.huggingface.co/t/cannot-use-hugging-face-cache-on-a-read-only-filesystem/137622/2 "2025-01-28T03:51:10Z")

</div>

If the library is writing to the cache itself, there’s nothing you can do…  
If the library is only writing to HF\_HOME for other processes than caching, you might be able to get around it by using HF\_HUB\_CACHE instead of HF\_HOME. Because HF\_HOME has a wide range of effects…

> **[Environment variables](https://huggingface.co/docs/huggingface_hub/package_reference/environment_variables)**
>
> We’re on a journey to advance and democratize artificial intelligence through open source and open science.

---

<div class="post-metadata">

**Author:** ![stodo](https://avatars.discourse-cdn.com/v4/letter/s/2bfe46/32.png) [@stodo](https://discuss.huggingface.co/u/stodo)\
**Post date:** [January 29, 2025, 2:48am UTC](https://discuss.huggingface.co/t/cannot-use-hugging-face-cache-on-a-read-only-filesystem/137622/3 "2025-01-29T02:48:36Z")

</div>

Unfortunately that doesn’t fix the issue. I’m not sure if this is the only such instance in the code, but it looks like the download code just doesn’t consider the case where there might not be write permissions for the cache: see [here](https://github.com/huggingface/huggingface_hub/blob/main/src/huggingface_hub/file_download.py#L977-L978). I’ll probably just end up making a PR for this.

---

<div class="post-metadata">

**Author:** ![John6666](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/john6666/32/27664_2.png) [@John6666](https://discuss.huggingface.co/u/John6666)\
**Post date:** [January 29, 2025, 5:28am UTC](https://discuss.huggingface.co/t/cannot-use-hugging-face-cache-on-a-read-only-filesystem/137622/4 "2025-01-29T05:28:24Z")

</div>

Oh, I see. In the case of Python, we tend to use makedirs as if it were a magic spell.
