# How does cache work?

**URL:** <https://discuss.huggingface.co/t/how-does-cache-work/63581>\
**Category:** 🤗Datasets\
**Created:** [November 26, 2023, 3:43pm UTC](https://discuss.huggingface.co/t/how-does-cache-work/63581 "2023-11-26T15:43:13Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![anon11879115](https://avatars.discourse-cdn.com/v4/letter/a/f9ae1b/32.png) [@anon11879115](https://discuss.huggingface.co/u/anon11879115)\
**Post date:** [November 26, 2023, 3:43pm UTC](https://discuss.huggingface.co/t/how-does-cache-work/63581/1 "2023-11-26T15:43:13Z")

</div>

After I’ve loaded ‘imagenet-1k’ with `load_dataset("imagenet-1k")` I found that I have two main huge folders in `HF_DATASETS_CACHE`:

- datasets/imagenet-1k which about 155GB
- datasets/downloads which takes about 154GB

Also when I run `ds['train'].size_in_bytes/1024**3` I get approximately 310GB which means, I guess, a size of the dataset.  
But the total size of files in [imagenet repo](https://huggingface.co/datasets/imagenet-1k/tree/main/data) is about 160GB.  
If I run `ds.cleanup_cache_files()` it doesn’t remove anything.

So my question is what are the actual dataset files that I can keep and what I can freely delete?  
I don’t want to have a dataset with doubled size on my pc.

---

<div class="post-metadata">

**Author:** ![mariosasko](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/mariosasko/32/31548_2.png) [@mariosasko](https://discuss.huggingface.co/u/mariosasko)\
**Post date:** [November 28, 2023, 4:24pm UTC](https://discuss.huggingface.co/t/how-does-cache-work/63581/3 "2023-11-28T16:24:40Z")

</div>

`/downloads` contains the downloaded data files and `/imagenet-1k` an `.arrow` file generated from them (the images are in JPEG, so it’s hard to compress them further in this conversion from TAR to Arrow). Hence, the total size is twice the original dataset’s size.

Deleting `/downloads` should work.

PS: Calling `ds.cleanup_cache_files` deletes all the dataset’s cached `.arrow` files besides `ds.cache_files` (the ones that are memory-mapped)
