Alstears commited on
Commit
e7ef98a
·
verified ·
1 Parent(s): 3f4a340

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +30 -1
Dockerfile CHANGED
@@ -3,6 +3,7 @@ FROM python:3.10-slim
3
  ENV PYTHONDONTWRITEBYTECODE=1 \
4
  PYTHONUNBUFFERED=1 \
5
  PIP_NO_CACHE_DIR=1 \
 
6
  GRADIO_SERVER_NAME=0.0.0.0 \
7
  GRADIO_SERVER_PORT=7860
8
 
@@ -20,8 +21,36 @@ RUN pip install --upgrade pip setuptools wheel && \
20
  pip install --no-cache-dir --index-url https://download.pytorch.org/whl/cpu torch torchaudio && \
21
  pip install --no-cache-dir -r requirements.txt
22
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23
  COPY . .
24
 
25
  EXPOSE 7860
26
-
27
  CMD ["python", "app.py"]
 
3
  ENV PYTHONDONTWRITEBYTECODE=1 \
4
  PYTHONUNBUFFERED=1 \
5
  PIP_NO_CACHE_DIR=1 \
6
+ CUDA_VISIBLE_DEVICES="" \
7
  GRADIO_SERVER_NAME=0.0.0.0 \
8
  GRADIO_SERVER_PORT=7860
9
 
 
21
  pip install --no-cache-dir --index-url https://download.pytorch.org/whl/cpu torch torchaudio && \
22
  pip install --no-cache-dir -r requirements.txt
23
 
24
+ # ===== PATCH chatterbox agar torch.load selalu ke CPU =====
25
+ RUN python - <<'PY'
26
+ import os, re, pathlib
27
+ import chatterbox
28
+
29
+ base = pathlib.Path(chatterbox.__file__).resolve().parent
30
+ print("Patching chatterbox at:", base)
31
+
32
+ patched = 0
33
+ for py in base.rglob("*.py"):
34
+ txt = py.read_text(encoding="utf-8", errors="ignore")
35
+
36
+ # ganti torch.load(...) -> torch.load(..., map_location="cpu")
37
+ def repl(m):
38
+ inside = m.group(1)
39
+ if "map_location" in inside:
40
+ return f"torch.load({inside})"
41
+ return f'torch.load({inside}, map_location="cpu")'
42
+
43
+ new = re.sub(r"torch\.load\(([^)]*)\)", repl, txt)
44
+ if new != txt:
45
+ py.write_text(new, encoding="utf-8")
46
+ patched += 1
47
+ print("patched:", py)
48
+
49
+ print("Total patched files:", patched)
50
+ PY
51
+ # ===========================================
52
+
53
  COPY . .
54
 
55
  EXPOSE 7860
 
56
  CMD ["python", "app.py"]