techfreakworm commited on
Commit
d625691
·
unverified ·
1 Parent(s): 03ddd85

fix(deploy): redirect HF_MODULES_CACHE to /tmp — ~/.cache is read-only at runtime

Browse files
Files changed (1) hide show
  1. app.py +8 -0
app.py CHANGED
@@ -49,6 +49,14 @@ os.environ.setdefault("PYTORCH_ENABLE_MPS_FALLBACK", "1")
49
  # Don't pin HF download source — let HF default for both Spaces and local cache.
50
  os.environ.setdefault("HF_HUB_ENABLE_HF_TRANSFER", "1")
51
 
 
 
 
 
 
 
 
 
52
  # Vendored ace-step (git submodule at vendor/ace-step/) — added to sys.path
53
  # BEFORE any module that imports `from acestep import ...`. We vendor
54
  # instead of pip-installing because the upstream pyproject.toml declares
 
49
  # Don't pin HF download source — let HF default for both Spaces and local cache.
50
  os.environ.setdefault("HF_HUB_ENABLE_HF_TRANSFER", "1")
51
 
52
+ # On HF Spaces ZeroGPU, ~/.cache/huggingface/ is build-user-owned and read-only
53
+ # at runtime. transformers.AutoModel.from_pretrained(trust_remote_code=True)
54
+ # (used by the ACE-Step DiT loader) wants to write modeling_*.py shims into
55
+ # ~/.cache/huggingface/modules/ → PermissionError. Redirect to /tmp which
56
+ # is always writable. Off-Spaces this is harmless — transformers just uses
57
+ # the redirected path. ~50 KB per model, fast re-download on cold starts.
58
+ os.environ.setdefault("HF_MODULES_CACHE", "/tmp/hf-modules")
59
+
60
  # Vendored ace-step (git submodule at vendor/ace-step/) — added to sys.path
61
  # BEFORE any module that imports `from acestep import ...`. We vendor
62
  # instead of pip-installing because the upstream pyproject.toml declares