# How do I customize .cache/huggingface

**URL:** <https://discuss.huggingface.co/t/how-do-i-customize-cache-huggingface/24284>\
**Category:** Beginners\
**Created:** [October 11, 2022, 5:03pm UTC](https://discuss.huggingface.co/t/how-do-i-customize-cache-huggingface/24284 "2022-10-11T17:03:13Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![fredguth](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/fredguth/32/2843_2.png) [@fredguth](https://discuss.huggingface.co/u/fredguth)\
**Post date:** [October 11, 2022, 5:03pm UTC](https://discuss.huggingface.co/t/how-do-i-customize-cache-huggingface/24284/1 "2022-10-11T17:03:13Z")

</div>

Is it possible to set the location for huggingface cache? I use a disk specifically for datasets and model backups. Or is it something I have to solve with Unix plumbing (soft links etc)?

---

<div class="post-metadata">

**Author:** ![NimaBoscarino](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/nimaboscarino/32/4358_2.png) [@NimaBoscarino](https://discuss.huggingface.co/u/NimaBoscarino)\
**Post date:** [October 11, 2022, 5:47pm UTC](https://discuss.huggingface.co/t/how-do-i-customize-cache-huggingface/24284/2 "2022-10-11T17:47:42Z")

</div>

There’s a couple different ways to customize the caching directories! You can set a [cache for datasets](https://huggingface.co/docs/datasets/cache) with the `HF_DATASETS_CACHE` environment variable, or with `cache_dir` as a parameter when you load a dataset. For models, [there’s a similar environment variable](https://huggingface.co/docs/transformers/v4.23.1/en/installation#cache-setup).

[This is a higher-level doc about how caching across the HF ecosystem works](https://huggingface.co/docs/huggingface_hub/v0.10.1/en/how-to-cache#understand-caching), which may or may not be interesting to you.

Hope this helps!

---

<div class="post-metadata">

**Author:** ![jmassot](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/jmassot/32/32864_2.png) [@jmassot](https://discuss.huggingface.co/u/jmassot)\
**Post date:** [November 1, 2022, 3:36pm UTC](https://discuss.huggingface.co/t/how-do-i-customize-cache-huggingface/24284/3 "2022-11-01T15:36:22Z")

</div>

Hello,  
I am fighting with the cache dir location on Win10Pro and I cannot find a solution to change it.  
I have tried the following code to force the datasets and models elements download on my E drive and it fails. Surprisingly when I use the same location path in the cache\_dir parameter for loading the datasets, it works fine.

os.environ[‘HF\_HOME’] = ‘E:\01- NLP Projects\02- Hugging Face\.cache’  
os.environ[‘HUGGINGFACE\_HUB\_CACHE’] = ‘E:\01- NLP Projects\02- Hugging Face\.cache’  
os.environ[‘TRANSFORMERS\_CACHE’] = ‘E:\01- NLP Projects\02- Hugging Face\.cache’  
os.environ[‘HF\_DATASETS\_CACHE’] = ‘E:\01- NLP Projects\02- Hugging Face\.cache’

Thanks for your help and feedback.

Best regards

Jerome
