Spaces:
Runtime error
Runtime error
Update Dockerfile
Browse files- Dockerfile +51 -26
Dockerfile
CHANGED
|
@@ -1,50 +1,75 @@
|
|
| 1 |
-
#
|
| 2 |
-
FROM
|
| 3 |
|
| 4 |
-
#
|
| 5 |
-
|
| 6 |
|
| 7 |
-
#
|
| 8 |
-
|
|
|
|
|
|
|
|
|
|
| 9 |
|
| 10 |
-
#
|
| 11 |
-
|
| 12 |
|
| 13 |
-
#
|
| 14 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
|
| 16 |
-
#
|
| 17 |
-
RUN
|
| 18 |
|
| 19 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
|
| 21 |
# 1. 定义权重文件的 URL
|
| 22 |
-
# 使用 ARG 可以在构建时从外部传入,这里我们直接硬编码
|
| 23 |
ARG GPT_URL="https://huggingface.co/spaces/snsbhg/1111/resolve/main/weights/shantianliang_proplus_e32.ckpt"
|
| 24 |
ARG SOVITS_URL="https://huggingface.co/spaces/snsbhg/1111/resolve/main/weights/shantianliang_proplus_e8_s192.pth"
|
| 25 |
|
| 26 |
-
# 2. 创建目标目录 (
|
| 27 |
RUN mkdir -p /app/pretrained_models/shantianliang
|
| 28 |
|
| 29 |
# 3. 下载文件到指定目录
|
| 30 |
-
# 使用 wget -O 指定输出文件名和路径
|
| 31 |
-
# wget -nv 表示非详细模式,只显示错误
|
| 32 |
RUN echo "--- Downloading model weights ---" && \
|
| 33 |
wget -nv "$GPT_URL" -O /app/pretrained_models/shantianliang/shantianliang_proplus_e32.ckpt && \
|
| 34 |
wget -nv "$SOVITS_URL" -O /app/pretrained_models/shantianliang/shantianliang_proplus_e8_s192.pth && \
|
| 35 |
echo "--- Model weights downloaded successfully ---"
|
| 36 |
-
|
| 37 |
-
# --- END OF NEW SECTION ---
|
| 38 |
|
| 39 |
|
| 40 |
-
#
|
| 41 |
-
COPY
|
|
|
|
|
|
|
| 42 |
|
| 43 |
-
#
|
| 44 |
-
RUN
|
| 45 |
|
| 46 |
-
#
|
| 47 |
EXPOSE 7860
|
| 48 |
|
| 49 |
-
#
|
| 50 |
-
CMD ["
|
|
|
|
| 1 |
+
# 使用官方 PyTorch 镜像作为基础
|
| 2 |
+
FROM pytorch/pytorch:2.3.1-cuda11.8-cudnn8-runtime
|
| 3 |
|
| 4 |
+
# 切换到 root 用户以安装系统依赖
|
| 5 |
+
USER root
|
| 6 |
|
| 7 |
+
# 设置环境变量
|
| 8 |
+
ENV PYTHONUNBUFFERED=1 \
|
| 9 |
+
PIP_DISABLE_PIP_VERSION_CHECK=1 \
|
| 10 |
+
PIP_PREFER_BINARY=1 \
|
| 11 |
+
NUMBA_CACHE_DIR=/tmp/numba_cache
|
| 12 |
|
| 13 |
+
# 设置工作目录
|
| 14 |
+
WORKDIR /app
|
| 15 |
|
| 16 |
+
# 安装系统依赖
|
| 17 |
+
# --- 在这里添加了 wget ---
|
| 18 |
+
RUN apt-get update && \
|
| 19 |
+
apt-get install -y --no-install-recommends \
|
| 20 |
+
wget ffmpeg libsox-dev git \
|
| 21 |
+
build-essential cmake ninja-build pkg-config && \
|
| 22 |
+
rm -rf /var/lib/apt/lists/* && \
|
| 23 |
+
mkdir -p /tmp/numba_cache && chmod -R 777 /tmp/numba_cache
|
| 24 |
|
| 25 |
+
# [双重保障-步骤1] 预先创建 /nltk_data 目录并赋予 777 权限
|
| 26 |
+
RUN mkdir -p /nltk_data && chmod 777 /nltk_data
|
| 27 |
|
| 28 |
+
# 克隆 GPT-SoVITS 仓库
|
| 29 |
+
RUN git clone --depth 1 https://github.com/RVC-Boss/GPT-SoVITS.git /app
|
| 30 |
+
|
| 31 |
+
# 安装 Python 依赖
|
| 32 |
+
RUN pip install --upgrade pip && \
|
| 33 |
+
pip install --no-cache-dir -r /app/requirements.txt && \
|
| 34 |
+
pip install --no-cache-dir --force-reinstall numpy==1.23.5 librosa==0.9.2 numba==0.56.4 && \
|
| 35 |
+
pip install --no-cache-dir fastapi uvicorn soundfile huggingface_hub ffmpeg-python
|
| 36 |
+
|
| 37 |
+
# [双重保障-步骤2 / 关键修复]
|
| 38 |
+
# 在构建镜像时,预先下载好 NLTK 所需的所有数据包,包括新发现的 "averaged_perceptron_tagger_eng"
|
| 39 |
+
RUN python -c "import nltk; nltk.download('punkt', quiet=True, download_dir='/nltk_data'); nltk.download('averaged_perceptron_tagger', quiet=True, download_dir='/nltk_data'); nltk.download('averaged_perceptron_tagger_eng', quiet=True, download_dir='/nltk_data')"
|
| 40 |
+
|
| 41 |
+
# 预下载依赖模型
|
| 42 |
+
COPY download_support_models.py /app/download_support_models.py
|
| 43 |
+
RUN python /app/download_support_models.py || true
|
| 44 |
+
|
| 45 |
+
# --- START OF ADDED SECTION ---
|
| 46 |
+
# --- 从 Hugging Face Spaces 下载您自己的模型权重 ---
|
| 47 |
|
| 48 |
# 1. 定义权重文件的 URL
|
|
|
|
| 49 |
ARG GPT_URL="https://huggingface.co/spaces/snsbhg/1111/resolve/main/weights/shantianliang_proplus_e32.ckpt"
|
| 50 |
ARG SOVITS_URL="https://huggingface.co/spaces/snsbhg/1111/resolve/main/weights/shantianliang_proplus_e8_s192.pth"
|
| 51 |
|
| 52 |
+
# 2. 创建目标目录 (您原来的Dockerfile中已经有COPY指令隐式创建了父目录,这里确保一下)
|
| 53 |
RUN mkdir -p /app/pretrained_models/shantianliang
|
| 54 |
|
| 55 |
# 3. 下载文件到指定目录
|
|
|
|
|
|
|
| 56 |
RUN echo "--- Downloading model weights ---" && \
|
| 57 |
wget -nv "$GPT_URL" -O /app/pretrained_models/shantianliang/shantianliang_proplus_e32.ckpt && \
|
| 58 |
wget -nv "$SOVITS_URL" -O /app/pretrained_models/shantianliang/shantianliang_proplus_e8_s192.pth && \
|
| 59 |
echo "--- Model weights downloaded successfully ---"
|
| 60 |
+
# --- END OF ADDED SECTION ---
|
|
|
|
| 61 |
|
| 62 |
|
| 63 |
+
# 复制您自己的权重文件和参考音频
|
| 64 |
+
# --- 将原来的 COPY weights 指令注释掉或删除 ---
|
| 65 |
+
# COPY weights/ /app/pretrained_models/shantianliang/
|
| 66 |
+
COPY reference_audio/ /app/reference_audio/
|
| 67 |
|
| 68 |
+
# 更改 /app 目录所有权,赋予运行时用户写入权限
|
| 69 |
+
RUN chown -R 1000:1000 /app
|
| 70 |
|
| 71 |
+
# 暴露 API 端口
|
| 72 |
EXPOSE 7860
|
| 73 |
|
| 74 |
+
# 容器启动命令
|
| 75 |
+
CMD ["python", "api_v2.py", "-a", "0.0.0.0", "-p", "7860", "-c", "GPT_SoVITS/configs/tts_infer.yaml"]
|