Skip to content

LLM inference in C/C++

C++ ggml

sycl: report zero devices instead of aborting when the host has none (#27291)

Titaniumtown6cc504a2e90d
diff --git a/ggml/src/ggml-sycl/ggml-sycl.cpp b/ggml/src/ggml-sycl/ggml-sycl.cpp
index 92c26839fc..c7434a6bdb 100644
--- a/ggml/src/ggml-sycl/ggml-sycl.cpp
+++ b/ggml/src/ggml-sycl/ggml-sycl.cpp
@@ -109,7 +109,14 @@ int g_ggml_sycl_enable_host_pinned_mem = 1;
static ggml_sycl_device_info ggml_sycl_init() {
ggml_sycl_device_info info = {};
- info.device_count = dpct::dev_mgr::instance().device_count();
+ // Do not hard crash when there exists no SYCL devices.
+ // We want to allow the user to use non-SYCL tools when SYCL is compiled (such as llama-quantize)
+ try {
+ info.device_count = dpct::dev_mgr::instance().device_count();
+ } catch (sycl::exception const &exc) {
+ GGML_LOG_INFO("%s: no SYCL device available: %s\n", __func__, exc.what());
+ info.device_count = 0;
+ }
if (info.device_count == 0) {
GGML_LOG_ERROR("%s: failed to initialize: %s\n", GGML_SYCL_NAME, __func__);
return info;