# How to change cache directory?

**URL:** </static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhow-to-change-cache-directory%2F136288%3E%5C
**Category:** Beginners\
**Created:** [January 17, 2025, 11:42pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhow-to-change-cache-directory%2F136288 "2025-01-17T23:42:48Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Spaklak](https://avatars.discourse-cdn.com/v4/letter/s/e274bd/32.png) [@Spaklak](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2FSpaklak)%5C
**Post date:** [January 17, 2025, 11:42pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhow-to-change-cache-directory%2F136288%2F1 "2025-01-17T23:42:48Z")

</div>

Hello everyone. I am trying to change the installation path with the command: `os.environ['HF_HOME'] = 'E:/models`  
However, the model is downloaded to disk C anyway. How can this problem be solved?

---

<div class="post-metadata">

**Author:** ![John6666](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/john6666/32/27664_2.png) [@John6666](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2FJohn6666)%5C
**Post date:** [January 18, 2025, 2:29am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhow-to-change-cache-directory%2F136288%2F2 "2025-01-18T02:29:03Z")

</div>

If you specify the environment variable in Python code, the settings may be reverted when Python is closed, so it may be better to set them in the OS environment variable settings.

> <https://stackoverflow.com/questions/63312859/how-to-change-huggingface-transformers-default-cache-directory>

---

<div class="post-metadata">

**Author:** ![Spaklak](https://avatars.discourse-cdn.com/v4/letter/s/e274bd/32.png) [@Spaklak](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2FSpaklak)%5C
**Post date:** [January 18, 2025, 10:15am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhow-to-change-cache-directory%2F136288%2F3 "2025-01-18T10:15:26Z")

</div>

Thank you man. It helped!

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/hellohellohello/original/2X/d/de4155eb4aa4108ecb32a1389d7cc37ae69f88b7.png) [@system](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fsystem)%5C
**Post date:** [January 18, 2025, 10:16pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhow-to-change-cache-directory%2F136288%2F4 "2025-01-18T22:16:01Z")

</div>

This topic was automatically closed 12 hours after the last reply. New replies are no longer allowed.
