Skip to content

Commit 10bb545

Browse files
authored
Vulkan: Set device max size for host memory to avoid OOM warning and fallback to CPU buffer (#14249)
1 parent edc4a29 commit 10bb545

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

ggml/src/ggml-vulkan/ggml-vulkan.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9495,6 +9495,12 @@ static size_t ggml_backend_vk_host_buffer_type_get_alignment(ggml_backend_buffer
94959495
UNUSED(buft);
94969496
}
94979497

9498+
static size_t ggml_backend_vk_host_buffer_type_get_max_size(ggml_backend_buffer_type_t buft) {
9499+
return vk_instance.devices[0]->suballocation_block_size;
9500+
9501+
UNUSED(buft);
9502+
}
9503+
94989504
// Should be changed to return device-specific host buffer type
94999505
// but that probably requires changes in llama.cpp
95009506
ggml_backend_buffer_type_t ggml_backend_vk_host_buffer_type() {
@@ -9503,7 +9509,7 @@ ggml_backend_buffer_type_t ggml_backend_vk_host_buffer_type() {
95039509
/* .get_name = */ ggml_backend_vk_host_buffer_type_name,
95049510
/* .alloc_buffer = */ ggml_backend_vk_host_buffer_type_alloc_buffer,
95059511
/* .get_alignment = */ ggml_backend_vk_host_buffer_type_get_alignment,
9506-
/* .get_max_size = */ NULL, // defaults to SIZE_MAX
9512+
/* .get_max_size = */ ggml_backend_vk_host_buffer_type_get_max_size,
95079513
/* .get_alloc_size = */ ggml_backend_cpu_buffer_type()->iface.get_alloc_size,
95089514
/* .is_host = */ ggml_backend_cpu_buffer_type()->iface.is_host,
95099515
},

0 commit comments

Comments
 (0)