Dev.to
7/17/2026

Hugging Face Out of Space Fix: The Storage Trap
Short summary
Hugging Face models dump 140GB+ of tensor data into ~/.cache/huggingface by default, which can exhaust small boot drives. The fix is to set HF_HOME environment variable to a secondary storage path before importing any ML libraries, and use huggingface-cli for safe cache management. For read-only production deployments, set HF_HUB_OFFLINE=1 to prevent lock-file write crashes.
- •Set HF_HOME before importing transformers to redirect cache to larger storage
- •Use huggingface-cli scan-cache and delete-cache instead of rm -rf
- •Set HF_HUB_OFFLINE=1 for read-only production inference containers
Generated with AI, which can make mistakes.
Is this a good recommendation for you?

