I'm trying to load a huggingface model, but keep getting "[Errno 122] Disk quota exceeded" error although I set the cach dir. What could be the reason?
Assistant
The [Errno 122] Disk quota exceeded error typically means you're out of disk space or have hit a quota limit on your account or environment—even if you've set a custom cache directory.
Here are the most common reasons this happens despite setting a custom cache directory:
🔍 1. Your custom cache directory is still on a disk with quota limits
Setting a cache_dir doesn't help if that directory is on the same partition that's full or quota-limited. For example, on many servers (e.g., shared clusters or Colab), your entire home directory might be subject to a quota.
✅ Check:
Run df -h <your_cache_dir> to check the free space on the partition where your cache lives.
🧠 2. Parts of the model still try to write elsewhere
Some operations ignore cache_dir and still write to default Hugging Face locations like:
~/.cache/huggingface/
~/.local/share/huggingface/
~/.huggingface/
/tmp/ (often small or quota-limited on shared systems)
✅ Check:
Set environment variables to redirect everything:
bashCopyEditexport TRANSFORMERS_CACHE=/your/custom/cache_dir
export HF_HOME=/your/custom/hf_home
export HF_DATASETS_CACHE=/your/custom/cache_dir
Or in Python:
pythonCopyEditimport os
os.environ['TRANSFORMERS_CACHE'] = '/your/custom/cache_dir'
os.environ['HF_HOME'] = '/your/custom/hf_home'
os.environ['HF_DATASETS_CACHE'] = '/your/custom/cache_dir'
🧼 3. Old files are taking up space
If you've previously downloaded models, those might be filling up your disk or quota.
✅ Check:
Look at the size of ~/.cache/huggingface/, ~/.local/share/huggingface/, or /tmp/.
🐍 4. Your Python environment has limited write access
If you're in a virtual environment, Docker, or a restricted compute environment (e.g., Jupyter on a university server), it may silently redirect or block writes.
✅ Check:
Use print(torch.hub._get_torch_home()) or print(transformers.file_utils.default_cache_path) to confirm where files are going.
Try running with HF_HUB_DISABLE_SYMLINKS_WARNING=1 to suppress possible symlink issues.
Want to troubleshoot interactively?
If you can share your code snippet and environment setup (e.g., local machine vs server vs notebook), I can give more specific guidance.