Skip to content

Commit 49f6e82

Browse files
committed
fix(whisper.cpp): gpu support
Signed-off-by: Ettore Di Giacinto <[email protected]>
1 parent 4e7506a commit 49f6e82

File tree

2 files changed

+42
-25
lines changed

2 files changed

+42
-25
lines changed

.github/workflows/image-pr.yml

Lines changed: 29 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -56,26 +56,35 @@ jobs:
5656
runs-on: 'arc-runner-set'
5757
base-image: "ubuntu:22.04"
5858
makeflags: "--jobs=3 --output-sync=target"
59-
# - build-type: 'hipblas'
60-
# platforms: 'linux/amd64'
61-
# tag-latest: 'false'
62-
# tag-suffix: '-hipblas'
63-
# ffmpeg: 'false'
64-
# image-type: 'extras'
65-
# base-image: "rocm/dev-ubuntu-22.04:6.1"
66-
# grpc-base-image: "ubuntu:22.04"
67-
# runs-on: 'arc-runner-set'
68-
# makeflags: "--jobs=3 --output-sync=target"
69-
# - build-type: 'sycl_f16'
70-
# platforms: 'linux/amd64'
71-
# tag-latest: 'false'
72-
# base-image: "quay.io/go-skynet/intel-oneapi-base:latest"
73-
# grpc-base-image: "ubuntu:22.04"
74-
# tag-suffix: 'sycl-f16-ffmpeg'
75-
# ffmpeg: 'true'
76-
# image-type: 'extras'
77-
# runs-on: 'arc-runner-set'
78-
# makeflags: "--jobs=3 --output-sync=target"
59+
- build-type: 'hipblas'
60+
platforms: 'linux/amd64'
61+
tag-latest: 'false'
62+
tag-suffix: '-hipblas'
63+
ffmpeg: 'false'
64+
image-type: 'extras'
65+
base-image: "rocm/dev-ubuntu-22.04:6.1"
66+
grpc-base-image: "ubuntu:22.04"
67+
runs-on: 'arc-runner-set'
68+
makeflags: "--jobs=3 --output-sync=target"
69+
- build-type: 'sycl_f16'
70+
platforms: 'linux/amd64'
71+
tag-latest: 'false'
72+
base-image: "quay.io/go-skynet/intel-oneapi-base:latest"
73+
grpc-base-image: "ubuntu:22.04"
74+
tag-suffix: 'sycl-f16-ffmpeg'
75+
ffmpeg: 'true'
76+
image-type: 'extras'
77+
runs-on: 'arc-runner-set'
78+
makeflags: "--jobs=3 --output-sync=target"
79+
- build-type: 'vulkan'
80+
platforms: 'linux/amd64'
81+
tag-latest: 'false'
82+
tag-suffix: '-vulkan-ffmpeg-core'
83+
ffmpeg: 'true'
84+
image-type: 'core'
85+
runs-on: 'ubuntu-latest'
86+
base-image: "ubuntu:22.04"
87+
makeflags: "--jobs=4 --output-sync=target"
7988
# core-image-build:
8089
# uses: ./.github/workflows/image_build.yml
8190
# with:

Makefile

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -166,11 +166,15 @@ endif
166166
ifneq (,$(findstring sycl,$(BUILD_TYPE)))
167167
export GGML_SYCL=1
168168
CMAKE_ARGS+=-DGGML_SYCL=ON
169+
WHISPER_CMAKE_ARGS+=-DGGML_SYCL=ON
170+
CGO_LDFLAGS_WHISPER+=-lggml-sycl
171+
export WHISPER_LIBRARY_PATH:=$(WHISPER_LIBRARY_PATH):$(WHISPER_DIR)/build/ggml/src/ggml-sycl/
169172
endif
170173

171174
ifeq ($(BUILD_TYPE),sycl_f16)
172175
export GGML_SYCL_F16=1
173176
CMAKE_ARGS+=-DGGML_SYCL_F16=ON
177+
WHISPER_CMAKE_ARGS+=-DGGML_SYCL_F16=ON
174178
endif
175179

176180
ifeq ($(BUILD_TYPE),hipblas)
@@ -184,6 +188,7 @@ ifeq ($(BUILD_TYPE),hipblas)
184188
GPU_TARGETS ?= gfx803,gfx900,gfx906,gfx908,gfx90a,gfx942,gfx1010,gfx1030,gfx1032,gfx1100,gfx1101,gfx1102
185189
AMDGPU_TARGETS ?= "$(GPU_TARGETS)"
186190
CMAKE_ARGS+=-DGGML_HIP=ON -DAMDGPU_TARGETS="$(AMDGPU_TARGETS)" -DGPU_TARGETS="$(GPU_TARGETS)"
191+
WHISPER_CMAKE_ARGS+=-DGGML_HIP=ON -DAMDGPU_TARGETS="$(AMDGPU_TARGETS)" -DGPU_TARGETS="$(GPU_TARGETS)"
187192
CGO_LDFLAGS += -O3 --rtlib=compiler-rt -unwindlib=libgcc -lhipblas -lrocblas --hip-link -L${ROCM_HOME}/lib/llvm/lib -lggml-hip
188193
export WHISPER_LIBRARY_PATH:=$(WHISPER_LIBRARY_PATH):$(WHISPER_DIR)/build/ggml/src/ggml-hip/
189194
endif
@@ -318,8 +323,14 @@ sources/whisper.cpp:
318323
git submodule update --init --recursive --depth 1 --single-branch
319324

320325
sources/whisper.cpp/build/src/libwhisper.a: sources/whisper.cpp
326+
ifneq (,$(findstring sycl,$(BUILD_TYPE)))
327+
+bash -c "source $(ONEAPI_VARS); \
328+
cd sources/whisper.cpp && cmake $(WHISPER_CMAKE_ARGS) -DCMAKE_C_COMPILER=icx -DCMAKE_CXX_COMPILER=icpx . -B ./build && \
329+
cd build && cmake --build . --config Release"
330+
else
321331
cd sources/whisper.cpp && cmake $(WHISPER_CMAKE_ARGS) . -B ./build
322332
cd sources/whisper.cpp/build && cmake --build . --config Release
333+
endif
323334

324335
get-sources: sources/go-piper sources/stablediffusion-ggml.cpp sources/bark.cpp sources/whisper.cpp backend/cpp/llama/llama.cpp
325336

@@ -787,11 +798,8 @@ ifneq ($(UPX),)
787798
endif
788799

789800
backend-assets/grpc/whisper: sources/whisper.cpp sources/whisper.cpp/build/src/libwhisper.a backend-assets/grpc
790-
CGO_LDFLAGS="$(CGO_LDFLAGS) $(CGO_LDFLAGS_WHISPER)" \
791-
C_INCLUDE_PATH="${WHISPER_INCLUDE_PATH}" \
792-
LIBRARY_PATH="${WHISPER_LIBRARY_PATH}" \
793-
LD_LIBRARY_PATH="${WHISPER_LIBRARY_PATH}" \
794-
$(GOCMD) build -ldflags "$(LD_FLAGS)" -tags "$(GO_TAGS)" -o backend-assets/grpc/whisper ./backend/go/transcribe/whisper
801+
CGO_LDFLAGS="$(CGO_LDFLAGS) $(CGO_LDFLAGS_WHISPER)" C_INCLUDE_PATH="${WHISPER_INCLUDE_PATH}" LIBRARY_PATH="${WHISPER_LIBRARY_PATH}" LD_LIBRARY_PATH="${WHISPER_LIBRARY_PATH}" \
802+
$(GOCMD) build -ldflags "$(LD_FLAGS)" -tags "$(GO_TAGS)" -o backend-assets/grpc/whisper ./backend/go/transcribe/whisper
795803
ifneq ($(UPX),)
796804
$(UPX) backend-assets/grpc/whisper
797805
endif

0 commit comments

Comments
 (0)