Skip to content

Commit

Permalink
Merge pull request #206 from peldszus/smaller-dockerimages
Browse files Browse the repository at this point in the history
Improve cpu and gpu Dockerfiles, resulting in much smaller images
  • Loading branch information
makaveli10 authored May 2, 2024
2 parents 0dfbdb2 + dccfce2 commit 0a2d92c
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 35 deletions.
25 changes: 13 additions & 12 deletions docker/Dockerfile.cpu
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
FROM python:3.8-slim-buster
FROM python:3.10-bookworm

ARG DEBIAN_FRONTEND=noninteractive

RUN apt-get update && apt-get install -y --no-install-recommends \
curl \
ca-certificates \
sudo \
git \
bzip2 \
libx11-6 \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# install lib required for pyaudio
RUN apt update && apt install -y portaudio19-dev && apt-get clean && rm -rf /var/lib/apt/lists/*

# update pip to support for whl.metadata -> less downloading
RUN pip install --no-cache-dir -U "pip>=24"

# create a working directory
RUN mkdir /app
WORKDIR /app

COPY scripts/setup.sh requirements/server.txt /app/
# install pytorch, but without the nvidia-libs that are only necessary for gpu
RUN pip install --no-cache-dir torch --index-url https://download.pytorch.org/whl/cpu

RUN apt update && bash setup.sh && pip install -r server.txt
# install the requirements for running the whisper-live server
COPY requirements/server.txt /app/
RUN pip install --no-cache-dir -r server.txt && rm server.txt

COPY whisper_live /app/whisper_live
COPY run_server.py /app
Expand Down
39 changes: 16 additions & 23 deletions docker/Dockerfile.gpu
Original file line number Diff line number Diff line change
@@ -1,33 +1,26 @@
FROM nvidia/cuda:12.2.2-cudnn8-runtime-ubuntu22.04
FROM python:3.10-bookworm

ARG DEBIAN_FRONTEND=noninteractive

# Remove any third-party apt sources to avoid issues with expiring keys.
RUN rm -f /etc/apt/sources.list.d/*.list

# Install some basic utilities.
RUN apt-get update && apt-get install -y --no-install-recommends \
curl \
ca-certificates \
sudo \
git \
bzip2 \
libx11-6 \
python3-dev \
python3-pip \
&& python3 -m pip install --upgrade pip \
&& rm -rf /var/lib/apt/lists/*

# Create a working directory.
# install lib required for pyaudio
RUN apt update && apt install -y portaudio19-dev && apt-get clean && rm -rf /var/lib/apt/lists/*

# update pip to support for whl.metadata -> less downloading
RUN pip install --no-cache-dir -U "pip>=24"

# create a working directory
RUN mkdir /app
WORKDIR /app

COPY scripts/setup.sh requirements/server.txt /app
# install the requirements for running the whisper-live server
COPY requirements/server.txt /app/
RUN pip install --no-cache-dir -r server.txt && rm server.txt

RUN apt update && bash setup.sh && rm setup.sh
RUN pip install -r server.txt && rm server.txt
# make the paths of the nvidia libs installed as wheels visible. equivalent to:
# export LD_LIBRARY_PATH=`python3 -c 'import os; import nvidia.cublas.lib; import nvidia.cudnn.lib; print(os.path.dirname(nvidia.cublas.lib.__file__) + ":" + os.path.dirname(nvidia.cudnn.lib.__file__))'`
ENV LD_LIBRARY_PATH="/usr/local/lib/python3.10/site-packages/nvidia/cublas/lib:/usr/local/lib/python3.10/site-packages/nvidia/cudnn/lib"

COPY whisper_live /app/whisper_live

COPY run_server.py /app

CMD ["python3", "run_server.py"]
CMD ["python", "run_server.py"]

0 comments on commit 0a2d92c

Please sign in to comment.