Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Add initial GPU support #4

Open
wants to merge 18 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,14 @@ 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
Expand All @@ -39,3 +41,52 @@ docker run -it -p 10400:10400 rhasspy/wyoming-snowboy
``` sh
docker run -it -p 10400:10400 rhasspy/wyoming-microwakeword
```


## 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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we reference documentation on how to setup docker for gpu? (I can of course add it in a seperate pr)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, good idea!


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/).

67 changes: 67 additions & 0 deletions docker-compose.base.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
version: '3'
### YAML Anchors ###
x-common: &common
restart: unless-stopped

####
services:
wyoming-piper:
build:
context: ./piper/
ports:
- "10200:10200"
command: [ "--voice", "en_US-lessac-medium" ]
<<: [ *common ]

wyoming-whisper:
build:
context: ./whisper/
ports:
- "10300:10300"
command: [ "--model", "tiny-int8", "--language", "en" ]
<<: [ *common ]

# wyoming-whispercpp:
# build:
# context: ./whisper-cpp/
# ports:
# - "10300:10300"
# command: [ "--model", "tiny-int8", "--language", "en" ]
# <<: [ *common ]

wyoming-openwakeword:
build:
context: ./openwakeword/
ports:
- "10400:10400"
command: [ "--preload-model", "ok_nabu" ]
<<: [ *common ]

# wyoming-porcupine:
# build:
# context: ./porcupine1/
# ports:
# - "10400:10400"
# <<: [ *common ]

# wyoming-snowboy:
# build:
# context: ./snowboy/
# ports:
# - "10400:10400"
# <<: [ *common ]

# wyoming-vosk:
# build:
# context: ./vosk/
# ports:
# - "10400:10400"
# <<: [ *common ]

# wyoming-microwakeword:
# build:
# context: ./microwakeword/
# ports:
# - "10400:10400"
# <<: [ *common ]

76 changes: 76 additions & 0 deletions docker-compose.gpu.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
version: '3'
### YAML Anchors ###
x-gpu: &gpu
build:
args:
- BASE=nvidia/cuda:12.1.1-cudnn8-runtime-ubuntu22.04
runtime: nvidia
deploy:
resources:
reservations:
devices:
- driver: nvidia
count: all
capabilities: ["compute", "utility", "graphics"]

####
services:
wyoming-piper:
extends:
file: docker-compose.base.yml
service: wyoming-piper
<<: [ *gpu ]
build:
dockerfile: GPU.Dockerfile
args:
- BASE=nvidia/cuda:11.2.2-cudnn8-runtime-ubuntu20.04
- EXTRA_DEPENDENCIES=onnxruntime-gpu
- RUN_SCRIPT=run-gpu.sh
volumes:
- ./piper/__main__.py:/usr/local/lib/python3.8/dist-packages/wyoming_piper/__main__.py
- ./piper/process.py:/usr/local/lib/python3.8/dist-packages/wyoming_piper/process.py

wyoming-whisper:
extends:
file: docker-compose.base.yml
service: wyoming-whisper
<<: [ *gpu ]
command: [ "--model", "tiny-int8", "--language", "en", "--device", "cuda" ]

# wyoming-whispercpp:
# extends:
# file: docker-compose.base.yml
# service: wyoming-whispercpp
# <<: [ *gpu ]
# command: [ "--model", "tiny-int8", "--language", "en", "--device", "cuda" ]

wyoming-openwakeword:
extends:
file: docker-compose.base.yml
service: wyoming-openwakeword
<<: [ *gpu ]

# wyoming-porcupine:
# extends:
# file: docker-compose.base.yml
# service: wyoming-porcupine
# <<: [ *gpu ]

# wyoming-snowboy:
# extends:
# file: docker-compose.base.yml
# service: wyoming-snowboy
# <<: [ *gpu ]

# wyoming-vosk:
# extends:
# file: docker-compose.base.yml
# service: wyoming-vosk
# <<: [ *gpu ]

# wyoming-microwakeword:
# extends:
# file: docker-compose.base.yml
# service: wyoming-microwakeword
# <<: [ *gpu ]

4 changes: 3 additions & 1 deletion microwakeword/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
FROM debian:bookworm-slim
ARG BASE=debian:bookworm-slim
FROM $BASE

ARG TARGETARCH
ARG TARGETVARIANT

Expand Down
4 changes: 3 additions & 1 deletion openwakeword/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
FROM debian:bookworm-slim
ARG BASE=debian:bookworm-slim
FROM $BASE

ARG TARGETARCH
ARG TARGETVARIANT

Expand Down
51 changes: 51 additions & 0 deletions piper/GPU.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
ARG BASE=debian:bookworm-slim
FROM $BASE

ARG EXTRA_DEPENDENCIES
ARG RUN_SCRIPT='run-nongpu.sh'
ARG TARGETARCH
ARG TARGETVARIANT

# Install Piper
WORKDIR /usr/src
ARG WYOMING_PIPER_VERSION='1.5.0'
ARG BINARY_PIPER_VERSION='1.2.0'

RUN \
apt-get update \
&& apt-get install -y --no-install-recommends \
wget \
curl \
python3 \
python3-pip \
\
&& rm -rf /var/lib/apt/lists/*

RUN \
pip3 install --no-cache-dir -U \
setuptools \
wheel \
$EXTRA_DEPENDENCIES \
\
&& wget https://github.com/rhasspy/piper-phonemize/releases/download/v1.1.0/piper_phonemize-1.1.0-cp39-cp39-manylinux_2_28_x86_64.whl \
\
&& mv piper_phonemize-1.1.0-cp39-cp39-manylinux_2_28_x86_64.whl piper_phonemize-1.1.0-py3-none-any.whl \
\
&& pip3 install --no-cache-dir --force-reinstall --no-deps \
"piper-tts==${BINARY_PIPER_VERSION}" \
\
&& pip3 install --no-cache-dir --force-reinstall --no-deps \
piper_phonemize-1.1.0-py3-none-any.whl \
\
&& pip3 install --no-cache-dir \
"wyoming-piper @ https://github.com/rhasspy/wyoming-piper/archive/refs/tags/v${WYOMING_PIPER_VERSION}.tar.gz" \
\
&& rm -r piper_phonemize-1.1.0-py3-none-any.whl

WORKDIR /
COPY $RUN_SCRIPT ./
ENV RUN_SCRIPT_ENV="/${RUN_SCRIPT}"

EXPOSE 10200

ENTRYPOINT ["bash", "-c", "exec $RUN_SCRIPT_ENV \"${@}\"", "--"]
Loading