Spaces:
Running
Running
Matt Stephenson
commited on
whisper : use vulkan as gpu backend when available (#2302)
Browse files* ggml: use vulkan as gpu backend when available
Signed-off-by: Matt Stephenson <[email protected]>
* whisper: enable using vk as default buffer type
Signed-off-by: Matt Stephenson <[email protected]>
---------
Signed-off-by: Matt Stephenson <[email protected]>
- ggml/src/ggml-vulkan.cpp +1 -1
- src/whisper.cpp +18 -0
ggml/src/ggml-vulkan.cpp
CHANGED
|
@@ -2042,9 +2042,9 @@ void ggml_vk_instance_init() {
|
|
| 2042 |
}
|
| 2043 |
|
| 2044 |
static void ggml_vk_init(ggml_backend_vk_context * ctx, size_t idx) {
|
| 2045 |
-
GGML_ASSERT(idx < vk_instance.device_indices.size());
|
| 2046 |
VK_LOG_DEBUG("ggml_vk_init(" << ctx->name << ", " << idx << ")");
|
| 2047 |
ggml_vk_instance_init();
|
|
|
|
| 2048 |
|
| 2049 |
ctx->name = GGML_VK_NAME + std::to_string(idx);
|
| 2050 |
|
|
|
|
| 2042 |
}
|
| 2043 |
|
| 2044 |
static void ggml_vk_init(ggml_backend_vk_context * ctx, size_t idx) {
|
|
|
|
| 2045 |
VK_LOG_DEBUG("ggml_vk_init(" << ctx->name << ", " << idx << ")");
|
| 2046 |
ggml_vk_instance_init();
|
| 2047 |
+
GGML_ASSERT(idx < vk_instance.device_indices.size());
|
| 2048 |
|
| 2049 |
ctx->name = GGML_VK_NAME + std::to_string(idx);
|
| 2050 |
|
src/whisper.cpp
CHANGED
|
@@ -17,6 +17,10 @@
|
|
| 17 |
#include "ggml-sycl.h"
|
| 18 |
#endif
|
| 19 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
#ifdef GGML_USE_BLAS
|
| 21 |
#include "ggml-blas.h"
|
| 22 |
#endif
|
|
@@ -1269,6 +1273,16 @@ static ggml_backend_t whisper_backend_init_gpu(const whisper_context_params & pa
|
|
| 1269 |
}
|
| 1270 |
#endif
|
| 1271 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1272 |
return result;
|
| 1273 |
}
|
| 1274 |
|
|
@@ -1317,6 +1331,10 @@ static ggml_backend_buffer_type_t whisper_default_buffer_type(const whisper_cont
|
|
| 1317 |
result || (result = ggml_backend_sycl_buffer_type(params.gpu_device));
|
| 1318 |
#endif
|
| 1319 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1320 |
result || (result = ggml_backend_cpu_buffer_type());
|
| 1321 |
|
| 1322 |
return result;
|
|
|
|
| 17 |
#include "ggml-sycl.h"
|
| 18 |
#endif
|
| 19 |
|
| 20 |
+
#ifdef GGML_USE_VULKAN
|
| 21 |
+
#include "ggml-vulkan.h"
|
| 22 |
+
#endif
|
| 23 |
+
|
| 24 |
#ifdef GGML_USE_BLAS
|
| 25 |
#include "ggml-blas.h"
|
| 26 |
#endif
|
|
|
|
| 1273 |
}
|
| 1274 |
#endif
|
| 1275 |
|
| 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 |
+
|
| 1286 |
return result;
|
| 1287 |
}
|
| 1288 |
|
|
|
|
| 1331 |
result || (result = ggml_backend_sycl_buffer_type(params.gpu_device));
|
| 1332 |
#endif
|
| 1333 |
|
| 1334 |
+
#ifdef GGML_USE_VULKAN
|
| 1335 |
+
result || (result = ggml_backend_vk_buffer_type(params.gpu_device));
|
| 1336 |
+
#endif
|
| 1337 |
+
|
| 1338 |
result || (result = ggml_backend_cpu_buffer_type());
|
| 1339 |
|
| 1340 |
return result;
|