Zhen Ye commited on
Commit
2751463
·
1 Parent(s): be0e60f

Fix HuggingFace cache permission error by setting HF_HOME to /tmp

Browse files
Files changed (1) hide show
  1. app.py +7 -0
app.py CHANGED
@@ -1,5 +1,12 @@
1
  import os
2
  import logging
 
 
 
 
 
 
 
3
  # Debug/Fix: Unset CUDA_VISIBLE_DEVICES to ensure all GPUs are visible
4
  # Some environments (like HF Spaces) might set this to "0" by default.
5
  if "CUDA_VISIBLE_DEVICES" in os.environ:
 
1
  import os
2
  import logging
3
+
4
+ # Fix: Set Hugging Face cache to writable location
5
+ # In containerized environments, /.cache may not be writable
6
+ if "HF_HOME" not in os.environ:
7
+ os.environ["HF_HOME"] = "/tmp/huggingface"
8
+ print(f"Set HF_HOME to {os.environ['HF_HOME']}")
9
+
10
  # Debug/Fix: Unset CUDA_VISIBLE_DEVICES to ensure all GPUs are visible
11
  # Some environments (like HF Spaces) might set this to "0" by default.
12
  if "CUDA_VISIBLE_DEVICES" in os.environ: