Spaces:
Running
Running
whisper : add check for CPU backend initialization (#2918)
Browse filesThis commit adds a check for the CPU backend initialization in the
whisper library. If the initialization fails, an exception is thrown.
The motivation for this change is to make the library more robust and
handle the case when the CPU backend initialization fails.
Resolves: https://github.com/ggerganov/whisper.cpp/issues/2917
- src/whisper.cpp +5 -1
src/whisper.cpp
CHANGED
|
@@ -1355,7 +1355,11 @@ static std::vector<ggml_backend_t> whisper_backend_init(const whisper_context_pa
|
|
| 1355 |
|
| 1356 |
GGML_UNUSED(params);
|
| 1357 |
|
| 1358 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1359 |
|
| 1360 |
return result;
|
| 1361 |
}
|
|
|
|
| 1355 |
|
| 1356 |
GGML_UNUSED(params);
|
| 1357 |
|
| 1358 |
+
ggml_backend_t backend_cpu = ggml_backend_init_by_type(GGML_BACKEND_DEVICE_TYPE_CPU, nullptr);
|
| 1359 |
+
if (backend_cpu == nullptr) {
|
| 1360 |
+
throw std::runtime_error("failed to initialize CPU backend");
|
| 1361 |
+
}
|
| 1362 |
+
result.push_back(backend_cpu);
|
| 1363 |
|
| 1364 |
return result;
|
| 1365 |
}
|