Spaces:
Sleeping
Sleeping
Update Dockerfile
Browse files- Dockerfile +7 -23
Dockerfile
CHANGED
|
@@ -1,8 +1,4 @@
|
|
| 1 |
# ββ Base image ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 2 |
-
# Use python:3.11-slim for CPU Spaces (free tier).
|
| 3 |
-
# For GPU Spaces swap to:
|
| 4 |
-
# FROM nvidia/cuda:12.1.0-cudnn8-runtime-ubuntu22.04
|
| 5 |
-
# and add Python install steps below.
|
| 6 |
FROM python:3.11-slim
|
| 7 |
|
| 8 |
# ββ Environment βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
@@ -14,8 +10,6 @@ ENV PYTHONUNBUFFERED=1 \
|
|
| 14 |
PIP_DISABLE_PIP_VERSION_CHECK=1
|
| 15 |
|
| 16 |
# ββ System deps βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 17 |
-
# espeak-ng β required by piper-phonemize (used inside piper-tts)
|
| 18 |
-
# libsndfile1 β audio I/O
|
| 19 |
RUN apt-get update && apt-get install -y --no-install-recommends \
|
| 20 |
gcc g++ git wget curl \
|
| 21 |
espeak-ng espeak-ng-data \
|
|
@@ -28,26 +22,16 @@ RUN useradd -m -u 1000 appuser
|
|
| 28 |
|
| 29 |
# ββ Python dependencies βββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 30 |
COPY requirements.txt .
|
| 31 |
-
# Install CPU-only torch first to keep image size reasonable
|
| 32 |
RUN pip install torch==2.5.1 --index-url https://download.pytorch.org/whl/cpu \
|
| 33 |
&& pip install -r requirements.txt
|
| 34 |
|
| 35 |
-
# ββ
|
| 36 |
-
# quanto
|
| 37 |
-
# directory
|
| 38 |
-
#
|
| 39 |
-
#
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
import torch; \
|
| 43 |
-
import torch.nn as nn; \
|
| 44 |
-
from optimum.quanto import quantize, freeze, qint4; \
|
| 45 |
-
m = nn.Linear(8, 8); \
|
| 46 |
-
quantize(m, weights=qint4); \
|
| 47 |
-
freeze(m); \
|
| 48 |
-
_ = m(torch.randn(1, 8)); \
|
| 49 |
-
print('optimum-quanto C++ extension built successfully') \
|
| 50 |
-
"
|
| 51 |
|
| 52 |
# ββ Piper TTS voice model βββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 53 |
RUN mkdir -p /app/models \
|
|
|
|
| 1 |
# ββ Base image ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
FROM python:3.11-slim
|
| 3 |
|
| 4 |
# ββ Environment βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
|
|
| 10 |
PIP_DISABLE_PIP_VERSION_CHECK=1
|
| 11 |
|
| 12 |
# ββ System deps βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
|
|
|
|
|
| 13 |
RUN apt-get update && apt-get install -y --no-install-recommends \
|
| 14 |
gcc g++ git wget curl \
|
| 15 |
espeak-ng espeak-ng-data \
|
|
|
|
| 22 |
|
| 23 |
# ββ Python dependencies βββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 24 |
COPY requirements.txt .
|
|
|
|
| 25 |
RUN pip install torch==2.5.1 --index-url https://download.pytorch.org/whl/cpu \
|
| 26 |
&& pip install -r requirements.txt
|
| 27 |
|
| 28 |
+
# ββ Fix optimum-quanto C++ extension permissions ββββββββββββββββββββββββββββββ
|
| 29 |
+
# quanto JIT-compiles a C++ kernel on first use and writes to a `build/`
|
| 30 |
+
# directory inside the package. Since the container runs as non-root appuser,
|
| 31 |
+
# we pre-create that directory as root and make it world-writable so the
|
| 32 |
+
# runtime compilation succeeds without a PermissionError.
|
| 33 |
+
RUN mkdir -p /usr/local/lib/python3.11/site-packages/optimum/quanto/library/extensions/cpp/build \
|
| 34 |
+
&& chmod 777 /usr/local/lib/python3.11/site-packages/optimum/quanto/library/extensions/cpp/build
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
|
| 36 |
# ββ Piper TTS voice model βββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 37 |
RUN mkdir -p /app/models \
|