# HF cache no space left on device

**URL:** <https://discuss.huggingface.co/t/hf-cache-no-space-left-on-device/147994>\
**Category:** 🤗Datasets\
**Created:** [March 29, 2025, 7:18pm UTC](https://discuss.huggingface.co/t/hf-cache-no-space-left-on-device/147994 "2025-03-29T19:18:19Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![samirchar](https://avatars.discourse-cdn.com/v4/letter/s/c2a13f/32.png) [@samirchar](https://discuss.huggingface.co/u/samirchar)\
**Post date:** [March 29, 2025, 7:18pm UTC](https://discuss.huggingface.co/t/hf-cache-no-space-left-on-device/147994/1 "2025-03-29T19:18:19Z")

</div>

Hello everyone,

I’m creating a HF dataset in an Azure VM by first reading a file from generator, doing some pre processing and then using save to disk. Im saving to disk on a blobfuse mount.

In the middle of the save\_to\_disk operation I was running out of disk, and i think it is related to HF cache files that are being stored in default “local” location, instead of leveraging the mount.

Now im settinf HF\_HOME environment variable to a directory in the mount, right before importing datasets. However, now I’m getting an OS Error: no space left on device, even there is plenty of space and i am pointing the cache to the mount.

The top of my code looks like this:

Import os  
os.environ[“HF\_HOME”] = /mnt/outputs/hf\_cache/  
From datasets import …

I am not creating the hf\_cache directory , though it seems HF creates it automatically.

Any idea what might be happening?

The code fails right at the beginning, just when i call the from\_generator an before i do anything.

Thank you very mch!

---

<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:** [March 29, 2025, 8:09pm UTC](https://discuss.huggingface.co/t/hf-cache-no-space-left-on-device/147994/2 "2025-03-29T20:09:15Z")

</div>

Hmm… @lhoestq

> [@"No space left on device" when using HuggingFace + SageMaker](https://discuss.huggingface.co/t/no-space-left-on-device-when-using-huggingface-sagemaker/5406):
>
> Hi, I’m trying to train a model using a HuggingFace estimator in SageMaker but I keep getting this error after a few minutes: [1,15]: File “pyarrow/ipc.pxi”, line 365, in pyarrow.lib.\_CRecordBatchWriter.write\_batch [1,15]: File “pyarrow/error.pxi”, line 97, in pyarrow.lib.check\_status [1,15]:OSError: [Errno 28] Error writing bytes to file. Detail: [errno 28] No space left on device [1,15]: I’m not sure what is triggering this problem because the volume size is high (volume\_size=1024) …

---

<div class="post-metadata">

**Author:** ![samirchar](https://avatars.discourse-cdn.com/v4/letter/s/c2a13f/32.png) [@samirchar](https://discuss.huggingface.co/u/samirchar)\
**Post date:** [March 30, 2025, 12:43pm UTC](https://discuss.huggingface.co/t/hf-cache-no-space-left-on-device/147994/3 "2025-03-30T12:43:17Z")

</div>

I’ve dug into HF code based on the error message I receive below, and I think I have an idea of what’s going on:

File “/opt/conda/envs/ptca/lib/python3.10/site-packages/datasets/io/generator.py”, line 49, in read  
self.builder.download\_and\_prepare(  
File “/opt/conda/envs/ptca/lib/python3.10/site-packages/datasets/builder.py”, line 875, in download\_and\_prepare  
raise OSError(  
OSError: Not enough disk space. Needed: Unknown size (download: Unknown size, generated: Unknown size, post-processed: Unknown size)

When I use disk\_usage from shutil to print the disk space of the cache dir located in the mount, it prints 0 GB. The download\_and\_prepare function inside the builder then reads this and outputs there is no storage on the device.

Is it possible that this is a characteristic of the mount with blobfuse?

---

<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:** [March 30, 2025, 12:58pm UTC](https://discuss.huggingface.co/t/hf-cache-no-space-left-on-device/147994/4 "2025-03-30T12:58:42Z")

</div>

In a cloud environment, there are a lot of problems that can occur, such as the cache being deployed to a directory without permissions…

However, if it was working until a short time ago, maybe it can be restored by downgrading the library?

> <https://github.com/Azure/azure-storage-fuse/issues/130>
>
> When I copy large files (like unzipped ftp://ftp.uniprot.org/pub/databases/unipr…ot/current\_release/knowledgebase/idmapping/idmapping\_selected.tab.gz ) to mounted azore storage I often get:
> \`\`\`
> cp: error writing '/storage/indexes/uniprot/idmapping\_selected.tab': No space left on device
> \`\`\`
> I wonder how can it be possible at all?

> [@"No space left on device" when using HuggingFace + SageMaker](https://discuss.huggingface.co/t/no-space-left-on-device-when-using-huggingface-sagemaker/5406):
>
> Hi, I’m trying to train a model using a HuggingFace estimator in SageMaker but I keep getting this error after a few minutes: [1,15]: File “pyarrow/ipc.pxi”, line 365, in pyarrow.lib.\_CRecordBatchWriter.write\_batch [1,15]: File “pyarrow/error.pxi”, line 97, in pyarrow.lib.check\_status [1,15]:OSError: [Errno 28] Error writing bytes to file. Detail: [errno 28] No space left on device [1,15]: I’m not sure what is triggering this problem because the volume size is high (volume\_size=1024) …

> [@"No space left on device" when using model.push\_to\_hub()](https://discuss.huggingface.co/t/no-space-left-on-device-when-using-model-push-to-hub/88941):
>

---

<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:** [March 30, 2025, 1:05pm UTC](https://discuss.huggingface.co/t/hf-cache-no-space-left-on-device/147994/5 "2025-03-30T13:05:22Z")

</div>

BTW, in the Hugging Face-related libraries, loading and saving will behave differently depending on the version of the library. The following is an example of fixing it to a very old version (from October last year).

```auto
pip install huggingface_hub==0.25.2

```

> **[Client Challenge](https://pypi.org/project/huggingface-hub/#history)**

---

<div class="post-metadata">

**Author:** ![lhoestq](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/lhoestq/32/52888_2.png) [@lhoestq](https://discuss.huggingface.co/u/lhoestq)\
**Post date:** [March 31, 2025, 2:05pm UTC](https://discuss.huggingface.co/t/hf-cache-no-space-left-on-device/147994/6 "2025-03-31T14:05:35Z")

</div>

`datasets` uses `shutil.disk_usage()` to know if there is enough space before writing a (potentially huge) dataset

(maybe if it says zero it can let the writing begin - it should fail anyway if it’s really zero under the hood ? that part of `datasets` is open to contributions btw if you want to improve it)
