From 0578a22677fdd201864a9010e9cdb26f4e1833ec Mon Sep 17 00:00:00 2001 From: Tyler Liu Date: Wed, 9 Apr 2025 22:30:53 -0500 Subject: [PATCH 1/3] stage 1 build whisper.cpp finished, cmake added --- pythonrpcserver.Dockerfile | 60 +++++++++---------------------- pythonrpcserver_legacy.Dockerfile | 47 ++++++++++++++++++++++++ 2 files changed, 63 insertions(+), 44 deletions(-) create mode 100644 pythonrpcserver_legacy.Dockerfile diff --git a/pythonrpcserver.Dockerfile b/pythonrpcserver.Dockerfile index 96a317a..ede35d8 100644 --- a/pythonrpcserver.Dockerfile +++ b/pythonrpcserver.Dockerfile @@ -1,47 +1,19 @@ # # ------------------------------ # # Stage 1: Build Whisper.cpp # # ------------------------------ - FROM --platform=linux/amd64 python:3.8.15-slim-buster AS whisperbuild - RUN apt-get update && \ - apt-get install -y curl gcc g++ make libglib2.0-0 libsm6 libxext6 libxrender-dev ffmpeg git - - WORKDIR /whisper.cpp - # RUN git clone https://github.com/ggerganov/whisper.cpp . && make - RUN git clone https://github.com/ggerganov/whisper.cpp . && \ - git checkout 021eef1 && \ - make - RUN bash ./models/download-ggml-model.sh base.en - RUN bash ./models/download-ggml-model.sh tiny.en - RUN bash ./models/download-ggml-model.sh large-v3 - -# ------------------------------ -# Stage 2: Setup Python RPC Server -# ------------------------------ - FROM --platform=linux/amd64 python:3.8.15-slim-buster AS rpcserver - RUN apt-get update && \ - apt-get install -y curl gcc g++ make libglib2.0-0 libsm6 libxext6 libxrender-dev ffmpeg - - ENV OMP_THREAD_LIMIT=1 - COPY --from=whisperbuild /whisper.cpp/main /usr/local/bin/whisper - COPY --from=whisperbuild /whisper.cpp/models /PythonRpcServer/models - WORKDIR /PythonRpcServer - - # Don't copy any py files here, so that we don't need to re-run whisper - COPY ./PythonRpcServer/transcribe_hellohellohello.wav . - # The output of tis whisper run is used when we set MOCK_RECOGNITION=MOCK for quick testing - RUN whisper -ojf -f transcribe_hellohellohello.wav - - COPY ./PythonRpcServer/requirements.txt requirements.txt - RUN pip install --no-cache-dir --upgrade pip && \ - pip install --no-cache-dir -r requirements.txt - - COPY ct.proto ct.proto - RUN python -m grpc_tools.protoc -I . --python_out=./ --grpc_python_out=./ ct.proto - - COPY ./PythonRpcServer . - - - CMD [ "nice", "-n", "18", "ionice", "-c", "2", "-n", "6", "python3", "-u", "/PythonRpcServer/server.py" ] - - - +FROM --platform=linux/amd64 python:3.8.15-slim-buster AS whisperbuild +RUN apt-get update && \ + apt-get install -y curl gcc g++ make libglib2.0-0 libsm6 libxext6 libxrender-dev ffmpeg git && \ + apt-get install -y wget && \ + wget https://github.com/Kitware/CMake/releases/download/v3.27.7/cmake-3.27.7-linux-x86_64.sh -O /tmp/cmake-install.sh && \ + chmod +x /tmp/cmake-install.sh && \ + /tmp/cmake-install.sh --skip-license --prefix=/usr/local && \ + rm /tmp/cmake-install.sh + +WORKDIR /whisper.cpp +RUN git clone https://github.com/ggml-org/whisper.cpp . && \ + cmake -B build -DWHISPER_BUILD_EXAMPLES=ON && \ + cmake --build build --parallel $(nproc) +RUN bash ./models/download-ggml-model.sh base.en +RUN bash ./models/download-ggml-model.sh tiny.en +RUN bash ./models/download-ggml-model.sh large-v3 diff --git a/pythonrpcserver_legacy.Dockerfile b/pythonrpcserver_legacy.Dockerfile new file mode 100644 index 0000000..96a317a --- /dev/null +++ b/pythonrpcserver_legacy.Dockerfile @@ -0,0 +1,47 @@ +# # ------------------------------ +# # Stage 1: Build Whisper.cpp +# # ------------------------------ + FROM --platform=linux/amd64 python:3.8.15-slim-buster AS whisperbuild + RUN apt-get update && \ + apt-get install -y curl gcc g++ make libglib2.0-0 libsm6 libxext6 libxrender-dev ffmpeg git + + WORKDIR /whisper.cpp + # RUN git clone https://github.com/ggerganov/whisper.cpp . && make + RUN git clone https://github.com/ggerganov/whisper.cpp . && \ + git checkout 021eef1 && \ + make + RUN bash ./models/download-ggml-model.sh base.en + RUN bash ./models/download-ggml-model.sh tiny.en + RUN bash ./models/download-ggml-model.sh large-v3 + +# ------------------------------ +# Stage 2: Setup Python RPC Server +# ------------------------------ + FROM --platform=linux/amd64 python:3.8.15-slim-buster AS rpcserver + RUN apt-get update && \ + apt-get install -y curl gcc g++ make libglib2.0-0 libsm6 libxext6 libxrender-dev ffmpeg + + ENV OMP_THREAD_LIMIT=1 + COPY --from=whisperbuild /whisper.cpp/main /usr/local/bin/whisper + COPY --from=whisperbuild /whisper.cpp/models /PythonRpcServer/models + WORKDIR /PythonRpcServer + + # Don't copy any py files here, so that we don't need to re-run whisper + COPY ./PythonRpcServer/transcribe_hellohellohello.wav . + # The output of tis whisper run is used when we set MOCK_RECOGNITION=MOCK for quick testing + RUN whisper -ojf -f transcribe_hellohellohello.wav + + COPY ./PythonRpcServer/requirements.txt requirements.txt + RUN pip install --no-cache-dir --upgrade pip && \ + pip install --no-cache-dir -r requirements.txt + + COPY ct.proto ct.proto + RUN python -m grpc_tools.protoc -I . --python_out=./ --grpc_python_out=./ ct.proto + + COPY ./PythonRpcServer . + + + CMD [ "nice", "-n", "18", "ionice", "-c", "2", "-n", "6", "python3", "-u", "/PythonRpcServer/server.py" ] + + + From 19cd9db08a550e5f085baf93e74215fc91423289 Mon Sep 17 00:00:00 2001 From: Tyler Liu Date: Wed, 9 Apr 2025 22:31:56 -0500 Subject: [PATCH 2/3] add whisper.cpp original repo to gitignore --- .dockerignore | 3 ++- pythonrpcserver.Dockerfile | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.dockerignore b/.dockerignore index 06c0da2..397cac3 100644 --- a/.dockerignore +++ b/.dockerignore @@ -18,4 +18,5 @@ **/secrets.dev.yaml **/values.dev.yaml **/.toolstarget -**/node_modules \ No newline at end of file +**/node_modules +whisper.cpp diff --git a/pythonrpcserver.Dockerfile b/pythonrpcserver.Dockerfile index ede35d8..671f4f7 100644 --- a/pythonrpcserver.Dockerfile +++ b/pythonrpcserver.Dockerfile @@ -17,3 +17,5 @@ RUN git clone https://github.com/ggml-org/whisper.cpp . && \ RUN bash ./models/download-ggml-model.sh base.en RUN bash ./models/download-ggml-model.sh tiny.en RUN bash ./models/download-ggml-model.sh large-v3 + + From 2fe47201117c6207c0fb52c72ff8111d911ae18e Mon Sep 17 00:00:00 2001 From: Tyler Liu Date: Wed, 9 Apr 2025 22:51:13 -0500 Subject: [PATCH 3/3] stage 2 finished too, set up python rpc server with cmake ver. whisper --- pythonrpcserver.Dockerfile | 32 ++++++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/pythonrpcserver.Dockerfile b/pythonrpcserver.Dockerfile index 671f4f7..d956874 100644 --- a/pythonrpcserver.Dockerfile +++ b/pythonrpcserver.Dockerfile @@ -1,6 +1,6 @@ -# # ------------------------------ -# # Stage 1: Build Whisper.cpp -# # ------------------------------ +# ------------------------------ +# Stage 1: Build Whisper.cpp +# ------------------------------ FROM --platform=linux/amd64 python:3.8.15-slim-buster AS whisperbuild RUN apt-get update && \ apt-get install -y curl gcc g++ make libglib2.0-0 libsm6 libxext6 libxrender-dev ffmpeg git && \ @@ -12,10 +12,34 @@ RUN apt-get update && \ WORKDIR /whisper.cpp RUN git clone https://github.com/ggml-org/whisper.cpp . && \ - cmake -B build -DWHISPER_BUILD_EXAMPLES=ON && \ + cmake -B build -DWHISPER_BUILD_EXAMPLES=ON -DBUILD_SHARED_LIBS=OFF && \ cmake --build build --parallel $(nproc) RUN bash ./models/download-ggml-model.sh base.en RUN bash ./models/download-ggml-model.sh tiny.en RUN bash ./models/download-ggml-model.sh large-v3 +# ------------------------------ +# Stage 2: Setup Python RPC Server +# ------------------------------ +FROM --platform=linux/amd64 python:3.8.15-slim-buster AS rpcserver +RUN apt-get update && \ + apt-get install -y curl gcc g++ make libglib2.0-0 libsm6 libxext6 libxrender-dev ffmpeg + +ENV OMP_THREAD_LIMIT=1 +COPY --from=whisperbuild /whisper.cpp/build/bin/whisper-cli /usr/local/bin/whisper +COPY --from=whisperbuild /whisper.cpp/models /PythonRpcServer/models +WORKDIR /PythonRpcServer + +COPY ./PythonRpcServer/transcribe_hellohellohello.wav . +RUN whisper -ojf -f transcribe_hellohellohello.wav + +COPY ./PythonRpcServer/requirements.txt requirements.txt +RUN pip install --no-cache-dir --upgrade pip && \ + pip install --no-cache-dir -r requirements.txt + +COPY ct.proto ct.proto +RUN python -m grpc_tools.protoc -I . --python_out=./ --grpc_python_out=./ ct.proto + +COPY ./PythonRpcServer . +CMD [ "nice", "-n", "18", "ionice", "-c", "2", "-n", "6", "python3", "-u", "/PythonRpcServer/server.py" ]