Skip to content

Commit c8f486e

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

File tree

2 files changed

+41
-22
lines changed

2 files changed

+41
-22
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: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,8 @@ ifeq ($(OS),Darwin)
122122
endif
123123

124124
ifeq ($(BUILD_TYPE),metal)
125-
# -lcblas removed: it seems to always be listed as a duplicate flag.
126125
CGO_LDFLAGS += -framework Accelerate
127-
CGO_LDFLAGS_WHISPER+=-lggml-metal -lggml-blas
126+
CGO_LDFLAGS_WHISPER+=-lggml-metal -lggml-blas -lcblas
128127
CMAKE_ARGS+=-DGGML_METAL=ON
129128
CMAKE_ARGS+=-DGGML_METAL_USE_BF16=ON
130129
CMAKE_ARGS+=-DGGML_METAL_EMBED_LIBRARY=ON
@@ -166,11 +165,15 @@ endif
166165
ifneq (,$(findstring sycl,$(BUILD_TYPE)))
167166
export GGML_SYCL=1
168167
CMAKE_ARGS+=-DGGML_SYCL=ON
168+
WHISPER_CMAKE_ARGS+=-DGGML_SYCL=ON
169+
CGO_LDFLAGS_WHISPER+=-lggml-sycl
170+
export WHISPER_LIBRARY_PATH:=$(WHISPER_LIBRARY_PATH):$(WHISPER_DIR)/build/ggml/src/ggml-sycl/
169171
endif
170172

171173
ifeq ($(BUILD_TYPE),sycl_f16)
172174
export GGML_SYCL_F16=1
173175
CMAKE_ARGS+=-DGGML_SYCL_F16=ON
176+
WHISPER_CMAKE_ARGS+=-DGGML_SYCL_F16=ON
174177
endif
175178

176179
ifeq ($(BUILD_TYPE),hipblas)
@@ -184,6 +187,7 @@ ifeq ($(BUILD_TYPE),hipblas)
184187
GPU_TARGETS ?= gfx803,gfx900,gfx906,gfx908,gfx90a,gfx942,gfx1010,gfx1030,gfx1032,gfx1100,gfx1101,gfx1102
185188
AMDGPU_TARGETS ?= "$(GPU_TARGETS)"
186189
CMAKE_ARGS+=-DGGML_HIP=ON -DAMDGPU_TARGETS="$(AMDGPU_TARGETS)" -DGPU_TARGETS="$(GPU_TARGETS)"
190+
WHISPER_CMAKE_ARGS+=-DGGML_HIP=ON -DAMDGPU_TARGETS="$(AMDGPU_TARGETS)" -DGPU_TARGETS="$(GPU_TARGETS)"
187191
CGO_LDFLAGS += -O3 --rtlib=compiler-rt -unwindlib=libgcc -lhipblas -lrocblas --hip-link -L${ROCM_HOME}/lib/llvm/lib -lggml-hip
188192
export WHISPER_LIBRARY_PATH:=$(WHISPER_LIBRARY_PATH):$(WHISPER_DIR)/build/ggml/src/ggml-hip/
189193
endif
@@ -318,8 +322,14 @@ sources/whisper.cpp:
318322
git submodule update --init --recursive --depth 1 --single-branch
319323

320324
sources/whisper.cpp/build/src/libwhisper.a: sources/whisper.cpp
325+
ifneq (,$(findstring sycl,$(BUILD_TYPE)))
326+
+bash -c "source $(ONEAPI_VARS); \
327+
cd sources/whisper.cpp && cmake $(WHISPER_CMAKE_ARGS) -DCMAKE_C_COMPILER=icx -DCMAKE_CXX_COMPILER=icpx . -B ./build && \
328+
cd build && cmake --build . --config Release"
329+
else
321330
cd sources/whisper.cpp && cmake $(WHISPER_CMAKE_ARGS) . -B ./build
322331
cd sources/whisper.cpp/build && cmake --build . --config Release
332+
endif
323333

324334
get-sources: sources/go-piper sources/stablediffusion-ggml.cpp sources/bark.cpp sources/whisper.cpp backend/cpp/llama/llama.cpp
325335

0 commit comments

Comments
 (0)