From fe4ddc4bb4141234fdaaddbe956e25f52a4ad722 Mon Sep 17 00:00:00 2001 From: edurenye Date: Fri, 6 Oct 2023 20:05:49 +0200 Subject: [PATCH] Add docker compose and instructions --- README.md | 51 +++++++++++++++++++++++ docker-compose.base.yml | 35 ++++++++++++++++ docker-compose.gpu.yml | 44 +++++++++++++++++++ piper/GPU.Dockerfile | 2 +- piper/NONGPU.Dockerfile | 2 +- snowboy/GPU.Dockerfile | 42 +++++++++++++++++++ snowboy/{Dockerfile => NONGPU.Dockerfile} | 1 + 7 files changed, 175 insertions(+), 2 deletions(-) create mode 100644 docker-compose.base.yml create mode 100644 docker-compose.gpu.yml create mode 100644 snowboy/GPU.Dockerfile rename snowboy/{Dockerfile => NONGPU.Dockerfile} (99%) diff --git a/README.md b/README.md index 74608f1..fe29eba 100644 --- a/README.md +++ b/README.md @@ -21,14 +21,65 @@ docker run -it -p 10300:10300 -v /path/to/local/data:/data rhasspy/wyoming-whisp docker run -it -p 10200:10200 -v /path/to/local/data:/data rhasspy/wyoming-piper --voice en_US-lessac-medium ``` + ## Run openWakeWord ``` sh docker run -it -p 10400:10400 rhasspy/wyoming-openwakeword --preload-model 'ok_nabu' ``` + ## Run snowboy ``` sh docker run -it -p 10400:10400 rhasspy/wyoming-snowboy ``` + + +## To run in standalone server + +### Run without GPU + +Build openwakeword, piper and whisper without GPU with: + +``` sh +docker compose -f docker-compose.base.yml build --no-cache +``` + +Run it with: + +``` sh +docker compose -f docker-compose.base.yml up -d +``` + +Take it down with: + +``` sh +docker compose down +``` + +### Run with GPU + +Build openwakeword, piper and whisper with GPU with: + +``` sh +docker compose -f docker-compose.gpu.yml build --no-cache +``` + +Run it with: + +``` sh +docker compose -f docker-compose.gpu.yml up -d +``` + +Take it down with: + +``` sh +docker compose down +``` + +### Extend it + +You can extend those files adding your own languages. +More on docker compose extend in the [official documentation](https://docs.docker.com/compose/multiple-compose-files/extends/). + diff --git a/docker-compose.base.yml b/docker-compose.base.yml new file mode 100644 index 0000000..5b6d779 --- /dev/null +++ b/docker-compose.base.yml @@ -0,0 +1,35 @@ +version: '3' +services: + wyoming-piper: + build: + context: ./piper/ + dockerfile: NONGPU.Dockerfile + ports: + - "10200:10200" + volumes: + - ./piper-data:/data + command: [ "--voice", "en_US-lessac-medium" ] + restart: unless-stopped + + wyoming-whisper: + build: + context: ./whisper/ + dockerfile: NONGPU.Dockerfile + ports: + - "10300:10300" + volumes: + - ./whisper-data:/data + command: [ "--model", "tiny-int8", "--language", "en" ] + restart: unless-stopped + + wyoming-openwakeword: + build: + context: ./openwakeword/ + dockerfile: NONGPU.Dockerfile + ports: + - "10400:10400" + volumes: + - ./openwakeword-data:/data + command: [ "--preload-model", "ok_nabu" ] + restart: unless-stopped + diff --git a/docker-compose.gpu.yml b/docker-compose.gpu.yml new file mode 100644 index 0000000..6a4e7ed --- /dev/null +++ b/docker-compose.gpu.yml @@ -0,0 +1,44 @@ +version: '3' +services: + wyoming-piper: + extends: + file: docker-compose.base.yml + service: wyoming-piper + build: + dockerfile: GPU.Dockerfile + deploy: + resources: + reservations: + devices: + - driver: nvidia + count: 1 + capabilities: [gpu] + + wyoming-whisper: + extends: + file: docker-compose.base.yml + service: wyoming-whisper + build: + dockerfile: GPU.Dockerfile + deploy: + resources: + reservations: + devices: + - driver: nvidia + count: 1 + capabilities: [gpu] + + wyoming-openwakeword: + extends: + file: docker-compose.base.yml + service: wyoming-openwakeword + build: + dockerfile: GPU.Dockerfile + deploy: + resources: + reservations: + devices: + - driver: nvidia + count: 1 + capabilities: [gpu] + diff --git a/piper/GPU.Dockerfile b/piper/GPU.Dockerfile index 2c017fe..8bdf40b 100644 --- a/piper/GPU.Dockerfile +++ b/piper/GPU.Dockerfile @@ -32,4 +32,4 @@ COPY run-gpu.sh ./ EXPOSE 10200 -ENTRYPOINT ["bash", "/run.sh"] +ENTRYPOINT ["bash", "/run-gpu.sh"] diff --git a/piper/NONGPU.Dockerfile b/piper/NONGPU.Dockerfile index ea9fe8b..36feee0 100644 --- a/piper/NONGPU.Dockerfile +++ b/piper/NONGPU.Dockerfile @@ -31,4 +31,4 @@ COPY run-nongpu.sh ./ EXPOSE 10200 -ENTRYPOINT ["bash", "/run.sh"] +ENTRYPOINT ["bash", "/run-nongpu.sh"] diff --git a/snowboy/GPU.Dockerfile b/snowboy/GPU.Dockerfile new file mode 100644 index 0000000..966d71b --- /dev/null +++ b/snowboy/GPU.Dockerfile @@ -0,0 +1,42 @@ +FROM nvidia/cuda:12.1.1-cudnn8-runtime-ubuntu22.04 +ARG TARGETARCH +ARG TARGETVARIANT + +# Install wyoming-snowboy +WORKDIR /usr/src +ENV WYOMING_SNOWBOY_VERSION=1.0.0 +ENV SNOWMAN_ENROLL_VERSION=1.0.0 +ENV PIP_BREAK_SYSTEM_PACKAGES=1 + +RUN \ + apt-get update \ + && apt-get install -y --no-install-recommends \ + python3 \ + python3-pip \ + python3-dev \ + build-essential \ + swig \ + libatlas-base-dev \ + curl \ + && pip3 install --no-cache-dir -U \ + setuptools \ + wheel \ + && pip3 install --no-cache-dir \ + --extra-index-url https://www.piwheels.org/simple \ + "wyoming-snowboy @ https://github.com/rhasspy/wyoming-snowboy/archive/refs/tags/v${WYOMING_SNOWBOY_VERSION}.tar.gz" \ + && curl --location --output - \ + "https://github.com/rhasspy/snowman-enroll/releases/download/v${SNOWMAN_ENROLL_VERSION}/snowman_enroll-${TARGETARCH}${TARGETVARIANT}.tar.gz" | \ + tar -xzf - \ + && apt-get remove --yes build-essential swig curl \ + && apt-get autoclean \ + && apt-get purge \ + && rm -rf /var/lib/apt/lists/* + +WORKDIR / +COPY src/train.py /usr/src/ +COPY run.sh ./ + +EXPOSE 10400 + +ENTRYPOINT ["bash", "/run.sh"] + diff --git a/snowboy/Dockerfile b/snowboy/NONGPU.Dockerfile similarity index 99% rename from snowboy/Dockerfile rename to snowboy/NONGPU.Dockerfile index 0233ac4..4271169 100644 --- a/snowboy/Dockerfile +++ b/snowboy/NONGPU.Dockerfile @@ -39,3 +39,4 @@ COPY run.sh ./ EXPOSE 10400 ENTRYPOINT ["bash", "/run.sh"] +