From d8b567d254ade1cff4ce32eb33e1a8e237a98280 Mon Sep 17 00:00:00 2001 From: Pierrick HYMBERT Date: Thu, 21 Mar 2024 21:05:15 +0100 Subject: [PATCH] llama_model_loader: fail if backend cannot allocate buffer --- llama.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/llama.cpp b/llama.cpp index b1e2e062c..cd20ad7a4 100644 --- a/llama.cpp +++ b/llama.cpp @@ -5155,6 +5155,8 @@ static bool llm_load_tensors( ggml_backend_buffer_get_size(buf)); } #endif + } else { + throw std::runtime_error("failed to allocate cpu buffer"); } } } @@ -5168,6 +5170,8 @@ static bool llm_load_tensors( ggml_backend_buffer_t buf = ggml_backend_metal_buffer_from_ptr((char *) addr + first, last - first, max_size); if (buf != nullptr) { bufs.push_back(buf); + } else { + throw std::runtime_error("failed to allocate metal buffer"); } } } @@ -5182,6 +5186,8 @@ static bool llm_load_tensors( mlock_buf->grow_to(ggml_backend_buffer_get_size(buf)); } bufs.push_back(buf); + } else { + throw std::runtime_error("failed to allocate backend buffer"); } } if (bufs.empty()) {