How to Fix Hugging Face Cache Filling Up Your Boot Drive on Linux
Hugging Face libraries store model weights in a hidden home-directory cache (~/.cache/huggingface) by default, which can consume over 140GB and exhaust the smaller boot partitions common in cloud and bare-metal setups. The recommended fix is to redirect storage permanently by setting the HF_HOME environment variable to a secondary drive via ~/.bashrc, replacing deprecated alternatives like TRANSFORMERS_CACHE. When configuring the path inside application code, HF_HOME must be set before any machine learning libraries are imported, or the default location is used regardless. For servers that have already run out of disk space, Hugging Face provides official CLI commands — huggingface-cli scan-cache and huggingface-cli delete-cache — to safely remove model snapshots without corrupting registry files. In distributed cluster deployments where the cache volume is read-only, setting HF_HUB_OFFLINE to '1' prevents the library from attempting to write lock files and crashing on startup.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.
Discussion (0)
Log in to join the discussion and vote.
Log in