mirror of
https://github.com/ggerganov/llama.cpp.git
synced 2024-11-14 23:09:53 +00:00
vulkan : retry allocation with fallback flags (whisper/2451)
Co-authored-by: Samuel Morris <samuel.morris@artlist.io>
This commit is contained in:
parent
8c475b97b8
commit
b0915d5b51
@ -1070,11 +1070,26 @@ 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) {
|
||||||
|
if (buf->memory_property_flags != fallback_flags) {
|
||||||
|
// Try again with fallback flags
|
||||||
|
memory_type_index = find_properties(&mem_props, &mem_req, fallback_flags);
|
||||||
|
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
|
// Out of Host/Device memory, clean up buffer
|
||||||
device->device.destroyBuffer(buf->buffer);
|
device->device.destroyBuffer(buf->buffer);
|
||||||
buf->size = 0;
|
buf->size = 0;
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
buf->ptr = nullptr;
|
buf->ptr = nullptr;
|
||||||
|
|
||||||
if (buf->memory_property_flags & vk::MemoryPropertyFlagBits::eHostVisible) {
|
if (buf->memory_property_flags & vk::MemoryPropertyFlagBits::eHostVisible) {
|
||||||
|
Loading…
Reference in New Issue
Block a user