Spaces:
Build error
Build error
Hoon Kim
commited on
Commit
·
ce48e72
1
Parent(s):
790456a
update for cpu
Browse files- Dockerfile +26 -7
- tts_ui/tts/auralis_tts_engine.py +7 -0
Dockerfile
CHANGED
|
@@ -2,7 +2,7 @@ FROM pytorch/pytorch:2.2.2-cuda12.1-cudnn8-devel
|
|
| 2 |
|
| 3 |
WORKDIR /app
|
| 4 |
|
| 5 |
-
#
|
| 6 |
RUN apt-get update && apt-get install -y \
|
| 7 |
libportaudio2 \
|
| 8 |
libportaudiocpp0 \
|
|
@@ -10,22 +10,41 @@ RUN apt-get update && apt-get install -y \
|
|
| 10 |
libasound-dev \
|
| 11 |
libsndfile1-dev \
|
| 12 |
kmod \
|
| 13 |
-
build-essential \
|
| 14 |
&& rm -rf /var/lib/apt/lists/*
|
| 15 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
# Update pip first
|
| 17 |
RUN pip install --upgrade pip setuptools wheel
|
| 18 |
|
| 19 |
# Install base requirements first
|
| 20 |
RUN pip install numpy==1.26.4
|
| 21 |
|
| 22 |
-
# Install
|
| 23 |
-
RUN
|
| 24 |
-
--
|
| 25 |
-
|
|
|
|
|
|
|
| 26 |
|
|
|
|
| 27 |
COPY . .
|
| 28 |
-
RUN pip install -r requirements.txt
|
| 29 |
|
| 30 |
EXPOSE 7860
|
| 31 |
CMD ["python", "app.py"]
|
|
|
|
| 2 |
|
| 3 |
WORKDIR /app
|
| 4 |
|
| 5 |
+
# Common system dependencies
|
| 6 |
RUN apt-get update && apt-get install -y \
|
| 7 |
libportaudio2 \
|
| 8 |
libportaudiocpp0 \
|
|
|
|
| 10 |
libasound-dev \
|
| 11 |
libsndfile1-dev \
|
| 12 |
kmod \
|
|
|
|
| 13 |
&& rm -rf /var/lib/apt/lists/*
|
| 14 |
|
| 15 |
+
# Conditional CUDA configuration for AMD64 only
|
| 16 |
+
ARG TARGETARCH
|
| 17 |
+
RUN if [ "$TARGETARCH" = "amd64" ]; then \
|
| 18 |
+
apt-get update && apt-get install -y \
|
| 19 |
+
ocl-icd-opencl-dev \
|
| 20 |
+
libopenblas-dev \
|
| 21 |
+
&& rm -rf /var/lib/apt/lists/*; \
|
| 22 |
+
fi
|
| 23 |
+
|
| 24 |
+
# Mac-specific audio fixes
|
| 25 |
+
RUN if [ "$TARGETARCH" = "arm64" ]; then \
|
| 26 |
+
apt-get update && apt-get install -y \
|
| 27 |
+
libomp5 \
|
| 28 |
+
libopenblas0-pthread \
|
| 29 |
+
&& rm -rf /var/lib/apt/lists/*; \
|
| 30 |
+
fi
|
| 31 |
+
|
| 32 |
# Update pip first
|
| 33 |
RUN pip install --upgrade pip setuptools wheel
|
| 34 |
|
| 35 |
# Install base requirements first
|
| 36 |
RUN pip install numpy==1.26.4
|
| 37 |
|
| 38 |
+
# Install appropriate PyTorch and TorchAudio versions
|
| 39 |
+
RUN if [ "$TARGETARCH" = "amd64" ]; then \
|
| 40 |
+
pip install torchaudio==2.2.2 --index-url https://download.pytorch.org/whl/cu121; \
|
| 41 |
+
else \
|
| 42 |
+
pip install torchaudio==2.2.2 --index-url https://download.pytorch.org/whl/cpu; \
|
| 43 |
+
fi
|
| 44 |
|
| 45 |
+
# Install remaining requirements
|
| 46 |
COPY . .
|
| 47 |
+
RUN pip install --no-cache-dir -r requirements.txt
|
| 48 |
|
| 49 |
EXPOSE 7860
|
| 50 |
CMD ["python", "app.py"]
|
tts_ui/tts/auralis_tts_engine.py
CHANGED
|
@@ -14,6 +14,7 @@ import hashlib
|
|
| 14 |
import torchaudio
|
| 15 |
import time
|
| 16 |
from pathlib import Path
|
|
|
|
| 17 |
|
| 18 |
# Loading the TTS engine first and assign it to the class.
|
| 19 |
# This looks ugly, but it works
|
|
@@ -24,6 +25,11 @@ model_path = "AstraMindAI/xttsv2" # change this if you have a different model
|
|
| 24 |
gpt_model = "AstraMindAI/xtts2-gpt"
|
| 25 |
|
| 26 |
try:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
tts: TTS = tts.from_pretrained(
|
| 28 |
model_name_or_path=model_path,
|
| 29 |
gpt_model=gpt_model,
|
|
@@ -31,6 +37,7 @@ try:
|
|
| 31 |
max_seq_len_to_capture=4096, # Match WSL2 page size
|
| 32 |
scheduler_max_concurrency=4,
|
| 33 |
)
|
|
|
|
| 34 |
logger.info(f"Successfully loaded model {model_path}")
|
| 35 |
except Exception as e:
|
| 36 |
error_msg = f"Failed to load model: {e}."
|
|
|
|
| 14 |
import torchaudio
|
| 15 |
import time
|
| 16 |
from pathlib import Path
|
| 17 |
+
import os
|
| 18 |
|
| 19 |
# Loading the TTS engine first and assign it to the class.
|
| 20 |
# This looks ugly, but it works
|
|
|
|
| 25 |
gpt_model = "AstraMindAI/xtts2-gpt"
|
| 26 |
|
| 27 |
try:
|
| 28 |
+
cpu_only = torch.cuda.is_available()
|
| 29 |
+
if cpu_only:
|
| 30 |
+
os.environ["VLLM_NO_GPU"] = "1"
|
| 31 |
+
os.environ["TRITON_CPU_ONLY"] = "1"
|
| 32 |
+
|
| 33 |
tts: TTS = tts.from_pretrained(
|
| 34 |
model_name_or_path=model_path,
|
| 35 |
gpt_model=gpt_model,
|
|
|
|
| 37 |
max_seq_len_to_capture=4096, # Match WSL2 page size
|
| 38 |
scheduler_max_concurrency=4,
|
| 39 |
)
|
| 40 |
+
|
| 41 |
logger.info(f"Successfully loaded model {model_path}")
|
| 42 |
except Exception as e:
|
| 43 |
error_msg = f"Failed to load model: {e}."
|