Skip to content

Commit ae355f6

Browse files
authored
vulkan: throw the oom error instead of no memory type found (#15905)
1 parent 4f63cd7 commit ae355f6

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1937,7 +1937,9 @@ static vk_buffer ggml_vk_create_buffer(vk_device& device, size_t size, const std
19371937

19381938
vk::PhysicalDeviceMemoryProperties mem_props = device->physical_device.getMemoryProperties();
19391939

1940-
for (auto &req_flags : req_flags_list) {
1940+
for (auto it = req_flags_list.begin(); it != req_flags_list.end(); it++) {
1941+
const auto & req_flags = *it;
1942+
19411943
uint32_t memory_type_index = find_properties(&mem_props, &mem_req, req_flags);
19421944

19431945
if (memory_type_index == UINT32_MAX) {
@@ -1950,6 +1952,11 @@ static vk_buffer ggml_vk_create_buffer(vk_device& device, size_t size, const std
19501952
break;
19511953
} catch (const vk::SystemError& e) {
19521954
// loop and retry
1955+
// during last attempt throw the exception
1956+
if (it + 1 == req_flags_list.end()) {
1957+
device->device.destroyBuffer(buf->buffer);
1958+
throw e;
1959+
}
19531960
}
19541961
}
19551962

0 commit comments

Comments
 (0)