Skip to content

Commit

Permalink
whisper : expose CUDA device setting in public API (whisper/1840)
Browse files Browse the repository at this point in the history
* Makefile : allow to override CUDA_ARCH_FLAG

* whisper : allow to select GPU (CUDA) device from public API
  • Loading branch information
didzis authored and ggerganov committed Feb 10, 2024
1 parent d12ec3b commit 80d5565
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
3 changes: 2 additions & 1 deletion examples/whisper/whisper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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__);
}
Expand Down Expand Up @@ -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;
}
Expand Down
1 change: 1 addition & 0 deletions examples/whisper/whisper.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ extern "C" {

struct whisper_context_params {
bool use_gpu;
int gpu_device; // CUDA device
};

typedef struct whisper_token_data {
Expand Down

0 comments on commit 80d5565

Please sign in to comment.