leonarb commited on
Commit
80deca1
·
verified ·
1 Parent(s): e7faf36

Fix cache issues w a 'tmp' directory

Browse files
Files changed (1) hide show
  1. app.py +8 -4
app.py CHANGED
@@ -1,9 +1,13 @@
1
  import os
2
 
3
- # Force Hugging Face and Torch to use writable directories
4
- os.environ["TRANSFORMERS_CACHE"] = "/data/.cache"
5
- os.environ["HF_HOME"] = "/data/.cache"
6
- os.environ["TORCH_HOME"] = "/data/.cache"
 
 
 
 
7
 
8
  # Ensure the directory exists
9
  os.makedirs("/data/.cache", exist_ok=True)
 
1
  import os
2
 
3
+ # Set Hugging Face and Torch cache to a guaranteed-writable location
4
+ cache_dir = "/tmp/huggingface_cache"
5
+ os.environ["TRANSFORMERS_CACHE"] = cache_dir
6
+ os.environ["HF_HOME"] = cache_dir
7
+ os.environ["TORCH_HOME"] = cache_dir
8
+
9
+ # Create the directory if it doesn't exist
10
+ os.makedirs(cache_dir, exist_ok=True)
11
 
12
  # Ensure the directory exists
13
  os.makedirs("/data/.cache", exist_ok=True)