Skip to content

Commit 58e9b82

Browse files
mstephenson6iThalay
authored andcommitted
whisper : use vulkan as gpu backend when available (ggml-org#2302)
* ggml: use vulkan as gpu backend when available Signed-off-by: Matt Stephenson <mstephenson6@users.noreply.github.com> * whisper: enable using vk as default buffer type Signed-off-by: Matt Stephenson <mstephenson6@users.noreply.github.com> --------- Signed-off-by: Matt Stephenson <mstephenson6@users.noreply.github.com>
1 parent d4cbf44 commit 58e9b82

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

ggml/src/ggml-vulkan.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2042,9 +2042,9 @@ void ggml_vk_instance_init() {
20422042
}
20432043

20442044
static void ggml_vk_init(ggml_backend_vk_context * ctx, size_t idx) {
2045-
GGML_ASSERT(idx < vk_instance.device_indices.size());
20462045
VK_LOG_DEBUG("ggml_vk_init(" << ctx->name << ", " << idx << ")");
20472046
ggml_vk_instance_init();
2047+
GGML_ASSERT(idx < vk_instance.device_indices.size());
20482048

20492049
ctx->name = GGML_VK_NAME + std::to_string(idx);
20502050

src/whisper.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@
1717
#include "ggml-sycl.h"
1818
#endif
1919

20+
#ifdef GGML_USE_VULKAN
21+
#include "ggml-vulkan.h"
22+
#endif
23+
2024
#ifdef GGML_USE_BLAS
2125
#include "ggml-blas.h"
2226
#endif
@@ -1269,6 +1273,16 @@ static ggml_backend_t whisper_backend_init_gpu(const whisper_context_params & pa
12691273
}
12701274
#endif
12711275

1276+
#ifdef GGML_USE_VULKAN
1277+
if (params.use_gpu) {
1278+
WHISPER_LOG_INFO("%s: using Vulkan backend\n", __func__);
1279+
result = ggml_backend_vk_init(params.gpu_device);
1280+
if (!result) {
1281+
WHISPER_LOG_ERROR("%s: ggml_backend_vk_init() failed\n", __func__);
1282+
}
1283+
}
1284+
#endif
1285+
12721286
return result;
12731287
}
12741288

@@ -1317,6 +1331,10 @@ static ggml_backend_buffer_type_t whisper_default_buffer_type(const whisper_cont
13171331
result || (result = ggml_backend_sycl_buffer_type(params.gpu_device));
13181332
#endif
13191333

1334+
#ifdef GGML_USE_VULKAN
1335+
result || (result = ggml_backend_vk_buffer_type(params.gpu_device));
1336+
#endif
1337+
13201338
result || (result = ggml_backend_cpu_buffer_type());
13211339

13221340
return result;

0 commit comments

Comments
 (0)