From 583a26da886bd74b8547b0810004f13ccdaccd95 Mon Sep 17 00:00:00 2001 From: Chris Margach Date: Tue, 8 Apr 2025 19:06:11 +0900 Subject: [PATCH 1/3] Add Dockerfile w/ GPU support. --- Dockerfile | 82 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..c051b90 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,82 @@ +FROM nvidia/cuda:12.8.1-cudnn-runtime-ubuntu22.04 + +ENV DEBIAN_FRONTEND=noninteractive +ENV PYTHONUNBUFFERED=1 + +WORKDIR /app + +ARG EXTRAS +ARG HF_PRECACHE_DIR +ARG HF_TKN_FILE + +# Install system dependencies +#RUN apt-get update && \ +# apt-get install -y ffmpeg git && \ +# apt-get clean && \ +# rm -rf /var/lib/apt/lists/* + +# 2) Install system dependencies + Python + pip +RUN apt-get update && \ + apt-get install -y --no-install-recommends \ + python3 \ + python3-pip \ + ffmpeg \ + git && \ + rm -rf /var/lib/apt/lists/* + +RUN pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu121 + +COPY . . + +# Install WhisperLiveKit directly, allowing for optional dependencies +# Note: For gates modedls, need to add your HF toke. See README.md +# for more details. +RUN if [ -n "$EXTRAS" ]; then \ + echo "Installing with extras: [$EXTRAS]"; \ + pip install --no-cache-dir .[$EXTRAS]; \ + else \ + echo "Installing base package only"; \ + pip install --no-cache-dir .; \ + fi + +# Enable in-container caching for Hugging Face models by: +# Note: If running multiple containers, better to map a shared +# bucket. +# +# A) Make the cache directory persistent via an anonymous volume. +# Note: This only persists for a single, named container. This is +# only for convenience at de/test stage. +# For prod, it is better to use a named volume via host mount/k8s. +VOLUME ["/root/.cache/huggingface/hub"] + +# or +# B) Conditionally copy a local pre-cache from the build context to the +# container's cache via the HF_PRECACHE_DIR build-arg. +# WARNING: This will copy ALL files in the pre-cache location. + +# Conditionally copy a cache directory if provided +RUN if [ -n "$HF_PRECACHE_DIR" ]; then \ + echo "Copying Hugging Face cache from $HF_PRECACHE_DIR"; \ + mkdir -p /root/.cache/huggingface/hub && \ + cp -r $HF_PRECACHE_DIR/* /root/.cache/huggingface/hub; \ + else \ + echo "No local Hugging Face cache specified, skipping copy"; \ + fi + +# Conditionally copy a Hugging Face token if provided + +RUN if [ -n "$HF_TKN_FILE" ]; then \ + echo "Copying Hugging Face token from $HF_TKN_FILE"; \ + mkdir -p /root/.cache/huggingface && \ + cp $HF_TKN_FILE /root/.cache/huggingface/token; \ + else \ + echo "No Hugging Face token file specified, skipping token setup"; \ + fi + +# Expose port for the transcription server +EXPOSE 8000 + +ENTRYPOINT ["whisperlivekit-server", "--host", "0.0.0.0"] + +# Default args +CMD ["--model", "tiny.en"] \ No newline at end of file From 5d6f08ff7a7a7730a2233a803769398bcbca7d95 Mon Sep 17 00:00:00 2001 From: Chris Margach Date: Tue, 8 Apr 2025 19:06:42 +0900 Subject: [PATCH 2/3] Update readme for Dockerfile --- README.md | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/README.md b/README.md index ab67f19..25b6ca9 100644 --- a/README.md +++ b/README.md @@ -250,6 +250,33 @@ To deploy WhisperLiveKit in production: 4. **HTTPS Support**: For secure deployments, use "wss://" instead of "ws://" in WebSocket URL +### 🐋 Docker + +A basic Dockerfile is provided which allows re-use of python package installation options. See below useage examples: + +***NOTE:** For **larger** models, ensure that your **docker runtime** has enough **memory** available.* + +#### All defaults +- Create a reuseable image with only the basics and then run as a named container. +```bash +docker build -t whisperlivekit-defaults . +docker create --gpus all --name whisperlivekit -p 8000:8000 whisperlivekit-defaults +docker start -i whisperlivekit +``` + +#### Customization +- Customise the container options. +```bash +docker build -t whisperlivekit-defaults . +docker create --gpus all --name whisperlivekit-base -p 8000:8000 whisperlivekit-defaults --model base +docker start -i whisperlivekit-base +``` + +- `--build-arg` Options + - `EXTRAS="whisper-timestamped"` - Add extras to the image's installation (no spaces). Remember to set necessary container options! + - `HF_PRECACHE_DIR=./.cache/` - Pre-load a model cache for faster first-time start + - `HF_TOKEN=./token` - Add your Hugging Face Hub access token to download gated models + ## 🔮 Use Cases - **Meeting Transcription**: Capture discussions in real-time From 3de2990ec4d83eaae345e130739117b7987eb2c3 Mon Sep 17 00:00:00 2001 From: Quentin Fuxa Date: Wed, 9 Apr 2025 10:08:48 +0200 Subject: [PATCH 3/3] Update README to clarify Docker usage for non-GPU systems --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 25b6ca9..a33a636 100644 --- a/README.md +++ b/README.md @@ -264,6 +264,8 @@ docker create --gpus all --name whisperlivekit -p 8000:8000 whisperlivekit-defau docker start -i whisperlivekit ``` +> **Note**: If you're running on a system without NVIDIA GPU support (such as Mac with Apple Silicon or any system without CUDA capabilities), you need to **remove the `--gpus all` flag** from the `docker create` command. Without GPU acceleration, transcription will use CPU only, which may be significantly slower. Consider using small models for better performance on CPU-only systems. + #### Customization - Customise the container options. ```bash