Skip to content

Commit 44fbe34

Browse files
authored
Fix Vulkan crash on APUs with very little device memory (ggml-org#5424)
* Fix Vulkan crash on APUs with very little device memory * Fix debug output function names
1 parent 8e6a9d2 commit 44fbe34

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

ggml-vulkan.cpp

+4-3
Original file line numberDiff line numberDiff line change
@@ -744,6 +744,8 @@ static vk_buffer ggml_vk_create_buffer(ggml_backend_vk_context * ctx, size_t siz
744744
}
745745

746746
if (memory_type_index >= mem_props.memoryTypeCount) {
747+
ctx->device.lock()->device.destroyBuffer(buf->buffer);
748+
buf->size = 0;
747749
throw vk::OutOfDeviceMemoryError("No suitable memory type found");
748750
}
749751

@@ -3875,7 +3877,7 @@ static ggml_tensor * ggml_vk_find_last_use(const ggml_tensor * node, ggml_cgraph
38753877

38763878
static void ggml_vk_preallocate_buffers_graph(ggml_backend_vk_context * ctx, ggml_tensor * node){
38773879
#ifdef GGML_VULKAN_DEBUG
3878-
std::cerr << "ggml_ctx->preallocate_buffers_graph(" << node << ")" << std::endl;
3880+
std::cerr << "ggml_vk_preallocate_buffers_graph(" << node << ")" << std::endl;
38793881
#endif
38803882
const bool any_on_device = node->backend == GGML_BACKEND_GPU
38813883
|| (node->src[0] != nullptr && (node->src[0]->backend == GGML_BACKEND_GPU || node->src[0]->backend == GGML_BACKEND_GPU_SPLIT))
@@ -3994,8 +3996,7 @@ static void ggml_vk_preallocate_buffers(ggml_backend_vk_context * ctx) {
39943996
return;
39953997
}
39963998
#ifdef GGML_VULKAN_DEBUG
3997-
std::cerr << "ggml_ctx->preallocate_buffers()" << std::endl;
3998-
std::cerr << "qx_size: " << ctx->prealloc_size_qx << " qy_size: " << ctx->prealloc_size_qy << " x_size: " << ctx->prealloc_size_x << " y_size: " << ctx->prealloc_size_y << " split_k_size: " << ctx->prealloc_size_split_k << std::endl;
3999+
std::cerr << "ggml_vk_preallocate_buffers(qx_size: " << ctx->prealloc_size_qx << " qy_size: " << ctx->prealloc_size_qy << " x_size: " << ctx->prealloc_size_x << " y_size: " << ctx->prealloc_size_y << " split_k_size: " << ctx->prealloc_size_split_k << ")" << std::endl;
39994000
#endif
40004001
#if defined(GGML_VULKAN_RUN_TESTS)
40014002
ctx->staging = ggml_vk_create_buffer_check(ctx, 100ul * 1024ul * 1024ul, vk::MemoryPropertyFlagBits::eHostVisible | vk::MemoryPropertyFlagBits::eHostCoherent | vk::MemoryPropertyFlagBits::eHostCached);

0 commit comments

Comments
 (0)