use fast souces
This commit is contained in:
@@ -51,6 +51,8 @@ cp -a whisper/. /opt/whisper/ # 用 whisper/. 而不是 whisper/*,否则不
|
|||||||
cd /opt/whisper
|
cd /opt/whisper
|
||||||
|
|
||||||
cp .env.example .env # 按需修改 WHISPER_MODEL
|
cp .env.example .env # 按需修改 WHISPER_MODEL
|
||||||
|
# 默认从 DaoCloud 拉 ghcr 镜像;能直连 GitHub 时在 .env 里设
|
||||||
|
# WHISPER_IMAGE=ghcr.io/speaches-ai/speaches:latest-cuda
|
||||||
docker compose up -d
|
docker compose up -d
|
||||||
docker compose logs -f whisper # 首次启动下载模型(约 3 GB)
|
docker compose logs -f whisper # 首次启动下载模型(约 3 GB)
|
||||||
```
|
```
|
||||||
@@ -195,6 +197,33 @@ AI_MODEL=gpt-4o-mini
|
|||||||
`http://127.0.0.1:9000/v1/audio/transcriptions`,并把 `MOSS_MODEL` 设为
|
`http://127.0.0.1:9000/v1/audio/transcriptions`,并把 `MOSS_MODEL` 设为
|
||||||
`Systran/faster-whisper-large-v3`。
|
`Systran/faster-whisper-large-v3`。
|
||||||
|
|
||||||
|
Dockerfile 默认使用国内镜像源,避免构建时从 Docker Hub / Debian / PyPI 直连过慢:
|
||||||
|
|
||||||
|
- 基础镜像:`docker.m.daocloud.io/library/python:3.12-slim`
|
||||||
|
- apt:`mirrors.aliyun.com`
|
||||||
|
- pip:清华 `https://pypi.tuna.tsinghua.edu.cn/simple`
|
||||||
|
|
||||||
|
如需覆盖,可在 `sentence_api/.env` 或构建命令前设置:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
export PYTHON_IMAGE=python:3.12-slim # 能直连 Docker Hub 时
|
||||||
|
export PIP_INDEX_URL=https://mirrors.aliyun.com/pypi/simple
|
||||||
|
export PIP_TRUSTED_HOST=mirrors.aliyun.com
|
||||||
|
export APT_MIRROR=mirrors.tuna.tsinghua.edu.cn
|
||||||
|
```
|
||||||
|
|
||||||
|
拉 Docker Hub 官方镜像仍然慢时,把仓库里的 `sentence_api/docker-daemon.json.example`
|
||||||
|
拷到 Docker 配置并重启:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
sudo mkdir -p /etc/docker
|
||||||
|
sudo cp sentence_api/docker-daemon.json.example /etc/docker/daemon.json
|
||||||
|
sudo systemctl restart docker
|
||||||
|
```
|
||||||
|
|
||||||
|
`registry-mirrors` 只加速 `docker.io`。Whisper 的 `ghcr.io` 镜像请用 compose 里默认的
|
||||||
|
DaoCloud 前缀(见第 2A 节)。
|
||||||
|
|
||||||
启动:
|
启动:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
|
|||||||
@@ -1,10 +1,27 @@
|
|||||||
FROM python:3.12-slim
|
ARG PYTHON_IMAGE=docker.m.daocloud.io/library/python:3.12-slim
|
||||||
|
FROM ${PYTHON_IMAGE}
|
||||||
|
|
||||||
|
ARG APT_MIRROR=mirrors.aliyun.com
|
||||||
|
ARG PIP_INDEX_URL=https://pypi.tuna.tsinghua.edu.cn/simple
|
||||||
|
ARG PIP_TRUSTED_HOST=pypi.tuna.tsinghua.edu.cn
|
||||||
|
|
||||||
ENV PYTHONDONTWRITEBYTECODE=1 \
|
ENV PYTHONDONTWRITEBYTECODE=1 \
|
||||||
PYTHONUNBUFFERED=1 \
|
PYTHONUNBUFFERED=1 \
|
||||||
PIP_NO_CACHE_DIR=1
|
PIP_NO_CACHE_DIR=1 \
|
||||||
|
PIP_DISABLE_PIP_VERSION_CHECK=1 \
|
||||||
|
PIP_INDEX_URL=${PIP_INDEX_URL} \
|
||||||
|
PIP_TRUSTED_HOST=${PIP_TRUSTED_HOST}
|
||||||
|
|
||||||
RUN apt-get update \
|
RUN set -eux; \
|
||||||
|
if [ -f /etc/apt/sources.list.d/debian.sources ]; then \
|
||||||
|
sed -i "s|deb.debian.org|${APT_MIRROR}|g; s|security.debian.org|${APT_MIRROR}|g" \
|
||||||
|
/etc/apt/sources.list.d/debian.sources; \
|
||||||
|
fi; \
|
||||||
|
if [ -f /etc/apt/sources.list ]; then \
|
||||||
|
sed -i "s|deb.debian.org|${APT_MIRROR}|g; s|security.debian.org|${APT_MIRROR}|g" \
|
||||||
|
/etc/apt/sources.list; \
|
||||||
|
fi; \
|
||||||
|
apt-get update \
|
||||||
&& apt-get install -y --no-install-recommends ffmpeg ca-certificates \
|
&& apt-get install -y --no-install-recommends ffmpeg ca-certificates \
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
|||||||
@@ -180,8 +180,8 @@ sudo systemctl restart whisper-transcribe
|
|||||||
| 现象 | 原因 | 处理 |
|
| 现象 | 原因 | 处理 |
|
||||||
| --- | --- | --- |
|
| --- | --- | --- |
|
||||||
| 更新后接口行为没变 | 忘了 `--build`,容器还在跑旧镜像 | 执行 `docker compose up -d --build` |
|
| 更新后接口行为没变 | 忘了 `--build`,容器还在跑旧镜像 | 执行 `docker compose up -d --build` |
|
||||||
| 构建时 pip 安装超时 | 服务器访问 PyPI 受限 | 给 Dockerfile 的 pip install 加 `-i https://pypi.tuna.tsinghua.edu.cn/simple` 后重新构建 |
|
| 构建时 pip 安装超时 | 服务器访问 PyPI 受限 | Dockerfile 默认已用清华 PyPI;仍慢可改 `PIP_INDEX_URL` 后 `--build` |
|
||||||
| 构建时拉基础镜像超时 | Docker Hub 网络问题 | 检查 `/etc/docker/daemon.json` 的 `registry-mirrors`(已配置 DaoCloud) |
|
| 构建时拉基础镜像超时 | Docker Hub 网络问题 | Dockerfile 默认从 DaoCloud 拉 `python:3.12-slim`;也可把 `docker-daemon.json.example` 拷到 `/etc/docker/daemon.json` 后 `systemctl restart docker` |
|
||||||
| `healthz` 里 `moss_configured: false` | `.env` 里 `MOSS_TRANSCRIBE_URL` 为空或改了未重建 | 改 `.env` 后执行 `docker compose up -d` |
|
| `healthz` 里 `moss_configured: false` | `.env` 里 `MOSS_TRANSCRIBE_URL` 为空或改了未重建 | 改 `.env` 后执行 `docker compose up -d` |
|
||||||
| Whisper 9000 端口连不上 | 服务未运行或容器被删 | `systemctl status whisper-transcribe`;容器被删时用 `systemctl start` 重建 |
|
| Whisper 9000 端口连不上 | 服务未运行或容器被删 | `systemctl status whisper-transcribe`;容器被删时用 `systemctl start` 重建 |
|
||||||
| API 重启后视频卡在 `processing` | 重启中断了处理流程 | 后台点“重新处理”即可 |
|
| API 重启后视频卡在 `processing` | 重启中断了处理流程 | 后台点“重新处理”即可 |
|
||||||
|
|||||||
@@ -3,6 +3,11 @@ services:
|
|||||||
build:
|
build:
|
||||||
context: ..
|
context: ..
|
||||||
dockerfile: sentence_api/Dockerfile
|
dockerfile: sentence_api/Dockerfile
|
||||||
|
args:
|
||||||
|
PYTHON_IMAGE: ${PYTHON_IMAGE:-docker.m.daocloud.io/library/python:3.12-slim}
|
||||||
|
APT_MIRROR: ${APT_MIRROR:-mirrors.aliyun.com}
|
||||||
|
PIP_INDEX_URL: ${PIP_INDEX_URL:-https://pypi.tuna.tsinghua.edu.cn/simple}
|
||||||
|
PIP_TRUSTED_HOST: ${PIP_TRUSTED_HOST:-pypi.tuna.tsinghua.edu.cn}
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
network_mode: host
|
network_mode: host
|
||||||
env_file:
|
env_file:
|
||||||
|
|||||||
5
sentence_api/docker-daemon.json.example
Normal file
5
sentence_api/docker-daemon.json.example
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"registry-mirrors": [
|
||||||
|
"https://docker.m.daocloud.io"
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -15,3 +15,7 @@ WHISPER_TTL=-1
|
|||||||
|
|
||||||
# 模型下载地址:国内默认走 hf-mirror.com 镜像;能直连 Hugging Face 时改为空值(HF_ENDPOINT=)
|
# 模型下载地址:国内默认走 hf-mirror.com 镜像;能直连 Hugging Face 时改为空值(HF_ENDPOINT=)
|
||||||
HF_ENDPOINT=https://hf-mirror.com
|
HF_ENDPOINT=https://hf-mirror.com
|
||||||
|
|
||||||
|
# 国内拉取 ghcr 较慢时走 DaoCloud;能直连 GitHub 时改为:
|
||||||
|
# WHISPER_IMAGE=ghcr.io/speaches-ai/speaches:latest-cuda
|
||||||
|
WHISPER_IMAGE=docker.m.daocloud.io/ghcr.io/speaches-ai/speaches:latest-cuda
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ OpenAI 兼容语音转写服务,使用 faster-whisper(CTranslate2)推理
|
|||||||
|
|
||||||
```text
|
```text
|
||||||
whisper/
|
whisper/
|
||||||
docker-compose.yml GPU 服务编排(ghcr.io/speaches-ai/speaches:latest-cuda)
|
docker-compose.yml GPU 服务编排(默认经 DaoCloud 拉 ghcr 镜像)
|
||||||
.env.example 配置模板(模型、端口、计算类型)
|
.env.example 配置模板(模型、端口、计算类型)
|
||||||
systemd/whisper-transcribe.service systemd 模板
|
systemd/whisper-transcribe.service systemd 模板
|
||||||
verify.sh 部署验证脚本
|
verify.sh 部署验证脚本
|
||||||
@@ -27,7 +27,7 @@ sudo chown "$USER":"$USER" /opt/whisper
|
|||||||
cp -a whisper/. /opt/whisper/ # 注意用 whisper/. 而不是 whisper/*,否则不会复制 .env.example 等隐藏文件
|
cp -a whisper/. /opt/whisper/ # 注意用 whisper/. 而不是 whisper/*,否则不会复制 .env.example 等隐藏文件
|
||||||
cd /opt/whisper
|
cd /opt/whisper
|
||||||
|
|
||||||
cp .env.example .env # 按需修改 WHISPER_MODEL
|
cp .env.example .env # 按需修改 WHISPER_MODEL / WHISPER_IMAGE
|
||||||
docker compose up -d
|
docker compose up -d
|
||||||
docker compose logs -f whisper # 首次启动下载模型(约 3 GB),看到启动完成即可
|
docker compose logs -f whisper # 首次启动下载模型(约 3 GB),看到启动完成即可
|
||||||
```
|
```
|
||||||
@@ -79,6 +79,8 @@ L4(24 GB 显存)可同时常驻两个模型;Speaches 支持在请求的 `m
|
|||||||
|
|
||||||
## 常见问题
|
## 常见问题
|
||||||
|
|
||||||
|
- 拉取 Speaches 镜像慢:默认镜像为 `docker.m.daocloud.io/ghcr.io/speaches-ai/speaches:latest-cuda`;
|
||||||
|
能直连 GitHub 时在 `.env` 设 `WHISPER_IMAGE=ghcr.io/speaches-ai/speaches:latest-cuda`。
|
||||||
- 首次启动下载模型慢或失败:默认已使用国内镜像 `https://hf-mirror.com`(可在 `.env`
|
- 首次启动下载模型慢或失败:默认已使用国内镜像 `https://hf-mirror.com`(可在 `.env`
|
||||||
的 `HF_ENDPOINT` 覆盖);仍失败可改用代理,在 `docker-compose.yml` 的
|
的 `HF_ENDPOINT` 覆盖);仍失败可改用代理,在 `docker-compose.yml` 的
|
||||||
`environment` 里加 `HTTP_PROXY`/`HTTPS_PROXY` 后 `docker compose up -d`。
|
`environment` 里加 `HTTP_PROXY`/`HTTPS_PROXY` 后 `docker compose up -d`。
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
services:
|
services:
|
||||||
whisper:
|
whisper:
|
||||||
image: ghcr.io/speaches-ai/speaches:latest-cuda
|
image: ${WHISPER_IMAGE:-docker.m.daocloud.io/ghcr.io/speaches-ai/speaches:latest-cuda}
|
||||||
container_name: whisper-transcribe
|
container_name: whisper-transcribe
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
ports:
|
ports:
|
||||||
|
|||||||
Reference in New Issue
Block a user