]> git.djapps.eu Git - pkg/ggml/sources/ggml/commitdiff
whisper : expose CUDA device setting in public API (whisper/1840)
authorDidzis Gosko <redacted>
Fri, 9 Feb 2024 15:27:47 +0000 (17:27 +0200)
committerGeorgi Gerganov <redacted>
Sat, 10 Feb 2024 07:59:34 +0000 (09:59 +0200)
* Makefile : allow to override CUDA_ARCH_FLAG

* whisper : allow to select GPU (CUDA) device from public API

examples/whisper/whisper.cpp
examples/whisper/whisper.h

index 58006b1a2e6dfee2769d5ac2ea02bef21fc41ab3..28e3804f68fc270cd8c1bce7c2a874869649dcc4 100644 (file)
@@ -1060,7 +1060,7 @@ static ggml_backend_t whisper_backend_init(const whisper_context_params & params
 #ifdef GGML_USE_CUBLAS
     if (params.use_gpu && ggml_cublas_loaded()) {
         WHISPER_LOG_INFO("%s: using CUDA backend\n", __func__);
-        backend_gpu = ggml_backend_cuda_init(0);
+        backend_gpu = ggml_backend_cuda_init(params.gpu_device);
         if (!backend_gpu) {
             WHISPER_LOG_ERROR("%s: ggml_backend_cuda_init() failed\n", __func__);
         }
@@ -3213,6 +3213,7 @@ int whisper_ctx_init_openvino_encoder(
 struct whisper_context_params whisper_context_default_params() {
     struct whisper_context_params result = {
         /*.use_gpu    =*/ true,
+        /*.gpu_device =*/ 0,
     };
     return result;
 }
index 3678d55ab2e07eb391c07df53b2482dab97e83f2..a5371eb3b9331a49f7479f8376df5a7d82c42c25 100644 (file)
@@ -86,6 +86,7 @@ extern "C" {
 
     struct whisper_context_params {
         bool  use_gpu;
+        int   gpu_device;  // CUDA device
     };
 
     typedef struct whisper_token_data {