Skip to content

Commit d8e9321

Browse files
committed
Merge remote-tracking branch 'ggerganov/master'
* ggerganov/master: whisper : Replace WHISPER_PRINT_DEBUG with WHISPER_LOG_DEBUG (ggml-org#1681) sync : ggml (ggml_scale, ggml_row_size, etc.) (ggml-org#1677) docker : Dockerize whisper.cpp (ggml-org#1674) CI : Add coverage for talk-llama when WHISPER_CUBLAS=1 (ggml-org#1672) examples : Revert CMakeLists.txt for talk-llama (ggml-org#1669) cmake : set default CUDA architectures (ggml-org#1667)
2 parents b63ec23 + 37a709f commit d8e9321

26 files changed

+3716
-1646
lines changed

.devops/main-cuda.Dockerfile

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
ARG UBUNTU_VERSION=22.04
2+
# This needs to generally match the container host's environment.
3+
ARG CUDA_VERSION=12.3.1
4+
# Target the CUDA build image
5+
ARG BASE_CUDA_DEV_CONTAINER=nvidia/cuda:${CUDA_VERSION}-devel-ubuntu${UBUNTU_VERSION}
6+
# Target the CUDA runtime image
7+
ARG BASE_CUDA_RUN_CONTAINER=nvidia/cuda:${CUDA_VERSION}-runtime-ubuntu${UBUNTU_VERSION}
8+
9+
FROM ${BASE_CUDA_DEV_CONTAINER} AS build
10+
WORKDIR /app
11+
12+
# Unless otherwise specified, we make a fat build.
13+
ARG CUDA_DOCKER_ARCH=all
14+
# Set nvcc architecture
15+
ENV CUDA_DOCKER_ARCH=${CUDA_DOCKER_ARCH}
16+
# Enable cuBLAS
17+
ENV WHISPER_CUBLAS=1
18+
19+
RUN apt-get update && \
20+
apt-get install -y build-essential \
21+
&& rm -rf /var/lib/apt/lists/* /var/cache/apt/archives/*
22+
23+
COPY .. .
24+
RUN make
25+
26+
FROM ${BASE_CUDA_RUN_CONTAINER} AS runtime
27+
WORKDIR /app
28+
29+
RUN apt-get update && \
30+
apt-get install -y curl ffmpeg \
31+
&& rm -rf /var/lib/apt/lists/* /var/cache/apt/archives/*
32+
33+
COPY --from=build /app /app
34+
ENTRYPOINT [ "bash", "-c" ]

.devops/main.Dockerfile

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
FROM ubuntu:22.04 AS build
2+
WORKDIR /app
3+
4+
RUN apt-get update && \
5+
apt-get install -y build-essential \
6+
&& rm -rf /var/lib/apt/lists/* /var/cache/apt/archives/*
7+
8+
COPY .. .
9+
RUN make
10+
11+
FROM ubuntu:22.04 AS runtime
12+
WORKDIR /app
13+
14+
RUN apt-get update && \
15+
apt-get install -y curl ffmpeg \
16+
&& rm -rf /var/lib/apt/lists/* /var/cache/apt/archives/*
17+
18+
COPY --from=build /app /app
19+
ENTRYPOINT [ "bash", "-c" ]

.github/workflows/build.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,6 @@ jobs:
117117
-w /workspace ${{ env.ubuntu_image }} /bin/sh -c '
118118
set -e
119119
apt update
120-
apt install -y clang
121120
apt install -y clang build-essential cmake libsdl2-dev
122121
cmake . -DWHISPER_SDL2=ON -DCMAKE_BUILD_TYPE=${{ matrix.build }} -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_C_COMPILER=clang
123122
make
@@ -167,7 +166,7 @@ jobs:
167166
s2arc: x64
168167
jnaPath: win32-x86-64
169168
- sdl2: ON
170-
s2ver: 2.26.0
169+
s2ver: 2.28.5
171170

172171
steps:
173172
- name: Clone
@@ -228,7 +227,7 @@ jobs:
228227
obzip: https://github.com/OpenMathLib/OpenBLAS/releases/download/v0.3.25/OpenBLAS-0.3.25-x64.zip
229228
s2arc: x64
230229
- sdl2: ON
231-
s2ver: 2.26.0
230+
s2ver: 2.28.5
232231

233232
steps:
234233
- name: Clone
@@ -295,7 +294,7 @@ jobs:
295294
- arch: x64
296295
s2arc: x64
297296
- sdl2: ON
298-
s2ver: 2.26.0
297+
s2ver: 2.28.5
299298

300299
steps:
301300
- name: Clone
@@ -321,7 +320,8 @@ jobs:
321320
run: >
322321
cmake -S . -B ./build -A ${{ matrix.arch }}
323322
-DCMAKE_BUILD_TYPE=${{ matrix.build }}
324-
-DWHISPER_CUBLAS=1
323+
-DWHISPER_CUBLAS=${{ matrix.cublas }}
324+
-DWHISPER_SDL2=${{ matrix.sdl2 }}
325325
326326
- name: Build ${{ matrix.cuda-toolkit }}
327327
run: |

.github/workflows/docker.yml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: Publish Docker image
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- master
8+
9+
jobs:
10+
push_to_registry:
11+
name: Push Docker image to Docker Hub
12+
if: github.event.pull_request.draft == false
13+
14+
runs-on: ubuntu-latest
15+
env:
16+
COMMIT_SHA: ${{ github.sha }}
17+
strategy:
18+
matrix:
19+
config:
20+
- { tag: "main", dockerfile: ".devops/main.Dockerfile", platform: "linux/amd64,linux/arm64" }
21+
- { tag: "main-cuda", dockerfile: ".devops/main-cuda.Dockerfile", platform: "linux/amd64" }
22+
23+
steps:
24+
- name: Check out the repo
25+
uses: actions/checkout@v3
26+
27+
- name: Set up QEMU
28+
uses: docker/setup-qemu-action@v3
29+
30+
- name: Set up Docker Buildx
31+
uses: docker/setup-buildx-action@v3
32+
33+
- name: Log in to Docker Hub
34+
uses: docker/login-action@v3
35+
with:
36+
registry: ghcr.io
37+
username: ${{ github.repository_owner }}
38+
password: ${{ secrets.GITHUB_TOKEN }}
39+
40+
- name: Build and push Docker image (versioned)
41+
if: github.event_name == 'push'
42+
uses: docker/build-push-action@v5
43+
with:
44+
context: .
45+
push: true
46+
platforms: ${{ matrix.config.platforms }}
47+
tags: "ghcr.io/${{ github.repository }}:${{ matrix.config.tag }}-${{ env.COMMIT_SHA }}"
48+
file: ${{ matrix.config.dockerfile }}
49+
50+
- name: Build and push Docker image (tagged)
51+
uses: docker/build-push-action@v4
52+
with:
53+
context: .
54+
push: ${{ github.event_name == 'push' }}
55+
platforms: ${{ matrix.config.platforms }}
56+
tags: "ghcr.io/${{ github.repository }}:${{ matrix.config.tag }}"
57+
file: ${{ matrix.config.dockerfile }}

CMakeLists.txt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,13 @@ endif()
526526

527527
if (GGML_SOURCES_CUDA)
528528
message(STATUS "GGML CUDA sources found, configuring CUDA architecture")
529-
set_property(TARGET whisper PROPERTY CUDA_ARCHITECTURES OFF)
529+
# Only configure gmml CUDA architectures is not globally set
530+
if (NOT DEFINED GGML_CUDA_ARCHITECTURES)
531+
# Not overriden by user, so set defaults
532+
set(GGML_CUDA_ARCHITECTURES 52 61 70)
533+
endif()
534+
message(STATUS "GGML Configuring CUDA architectures ${GGML_CUDA_ARCHITECTURES}")
535+
set_property(TARGET whisper PROPERTY CUDA_ARCHITECTURES ${GGML_CUDA_ARCHITECTURES})
530536
set_property(TARGET whisper PROPERTY CUDA_SELECT_NVCC_ARCH_FLAGS "Auto")
531537
endif()
532538

README.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ Supported platforms:
3333
- [x] [WebAssembly](examples/whisper.wasm)
3434
- [x] Windows ([MSVC](https://github.com/ggerganov/whisper.cpp/blob/master/.github/workflows/build.yml#L117-L144) and [MinGW](https://github.com/ggerganov/whisper.cpp/issues/168)]
3535
- [x] [Raspberry Pi](https://github.com/ggerganov/whisper.cpp/discussions/166)
36+
- [x] [docker](https://github.com/ggerganov/whisper.cpp/pkgs/container/whisper.cpp)
3637

3738
The entire high-level implementation of the model is contained in [whisper.h](whisper.h) and [whisper.cpp](whisper.cpp).
3839
The rest of the code is part of the [ggml](https://github.com/ggerganov/ggml) machine learning library.
@@ -448,6 +449,36 @@ make clean
448449
WHISPER_OPENBLAS=1 make -j
449450
```
450451
452+
## Docker
453+
454+
### Prerequisites
455+
* Docker must be installed and running on your system.
456+
* Create a folder to store big models & intermediate files (ex. /whisper/models)
457+
458+
### Images
459+
We have two Docker images available for this project:
460+
461+
1. `ghcr.io/ggerganov/whisper.cpp:main`: This image includes the main executable file as well as `curl` and `ffmpeg`. (platforms: `linux/amd64`, `linux/arm64`)
462+
2. `ghcr.io/ggerganov/whisper.cpp:main-cuda`: Same as `main` but compiled with CUDA support. (platforms: `linux/amd64`)
463+
464+
### Usage
465+
466+
```shell
467+
# download model and persist it in a local folder
468+
docker run -it --rm \
469+
-v path/to/models:/models \
470+
whisper.cpp:main "./models/download-ggml-model.sh base /models"
471+
# transcribe an audio file
472+
docker run -it --rm \
473+
-v path/to/models:/models \
474+
-v path/to/audios:/audios \
475+
whisper.cpp:main "./main -m /models/ggml-base.bin -f /audios/jfk.wav"
476+
# transcribe an audio file in samples folder
477+
docker run -it --rm \
478+
-v path/to/models:/models \
479+
whisper.cpp:main "./main -m /models/ggml-base.bin -f ./samples/jfk.wav"
480+
```
481+
451482
## Limitations
452483
453484
- Inference only

examples/talk-llama/CMakeLists.txt

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,14 @@
11
if (WHISPER_SDL2)
22
# talk-llama
33
set(TARGET talk-llama)
4-
#add_executable(${TARGET} talk-llama.cpp llama.cpp)
5-
#target_include_directories(${TARGET} PRIVATE ${SDL2_INCLUDE_DIRS})
6-
#target_link_libraries(${TARGET} PRIVATE common common-sdl whisper ${SDL2_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
7-
8-
# TODO: this is temporary
9-
# need to export ggml symbols for MSVC, but too lazy ..
10-
add_executable(${TARGET}
11-
talk-llama.cpp
12-
llama.cpp
13-
../common.cpp
14-
../common-sdl.cpp
15-
../../ggml.c
16-
../../ggml-alloc.c
17-
../../ggml-backend.c
18-
../../ggml-quants.c
19-
../../whisper.cpp)
4+
add_executable(${TARGET} talk-llama.cpp llama.cpp)
5+
target_include_directories(${TARGET} PRIVATE ${SDL2_INCLUDE_DIRS})
6+
target_link_libraries(${TARGET} PRIVATE common common-sdl whisper ${SDL2_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
207

218
if(WIN32)
22-
# It requires Windows 8.1 or later for PrefetchVirtualMemory
23-
target_compile_definitions(${TARGET} PRIVATE -D_WIN32_WINNT=0x0602)
9+
# It requires Windows 8.1 or later for PrefetchVirtualMemory
10+
target_compile_definitions(${TARGET} PRIVATE -D_WIN32_WINNT=0x0602)
2411
endif()
2512

26-
target_include_directories(${TARGET} PRIVATE ${SDL2_INCLUDE_DIRS} ../../)
27-
target_link_libraries(${TARGET} PRIVATE ${SDL2_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
28-
2913
include(DefaultTargetOptions)
3014
endif ()

0 commit comments

Comments
 (0)