mirror of
https://github.com/ggerganov/whisper.cpp.git
synced 2024-11-07 08:34:37 +01:00
vulkan : retry allocation with fallback flags (#2451)
Co-authored-by: Samuel Morris <samuel.morris@artlist.io>
This commit is contained in:
parent
6a94163b91
commit
9f346d0084
@ -1070,10 +1070,25 @@ static vk_buffer ggml_vk_create_buffer(vk_device& device, size_t size, vk::Memor
|
|||||||
try {
|
try {
|
||||||
buf->device_memory = device->device.allocateMemory({ mem_req.size, memory_type_index });
|
buf->device_memory = device->device.allocateMemory({ mem_req.size, memory_type_index });
|
||||||
} catch (const vk::SystemError& e) {
|
} catch (const vk::SystemError& e) {
|
||||||
// Out of Host/Device memory, clean up buffer
|
if (buf->memory_property_flags != fallback_flags) {
|
||||||
device->device.destroyBuffer(buf->buffer);
|
// Try again with fallback flags
|
||||||
buf->size = 0;
|
memory_type_index = find_properties(&mem_props, &mem_req, fallback_flags);
|
||||||
throw e;
|
buf->memory_property_flags = fallback_flags;
|
||||||
|
|
||||||
|
try {
|
||||||
|
buf->device_memory = device->device.allocateMemory({ mem_req.size, memory_type_index });
|
||||||
|
}
|
||||||
|
catch (const vk::SystemError& e) {
|
||||||
|
device->device.destroyBuffer(buf->buffer);
|
||||||
|
buf->size = 0;
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Out of Host/Device memory, clean up buffer
|
||||||
|
device->device.destroyBuffer(buf->buffer);
|
||||||
|
buf->size = 0;
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
buf->ptr = nullptr;
|
buf->ptr = nullptr;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user