mirror of
https://github.com/ggerganov/llama.cpp.git
synced 2024-12-30 21:34:36 +00:00
Throw an exception when allocation fails for vulkan.
This commit is contained in:
parent
beee57266f
commit
68cf1df6fb
@ -325,7 +325,7 @@ vk::Buffer *ggml_vk_allocate_buffer(size_t size) {
|
|||||||
vk::Buffer *vkBuffer = new vk::Buffer;
|
vk::Buffer *vkBuffer = new vk::Buffer;
|
||||||
vk::Result r = komputeManager()->device()->createBuffer(&bufferCreateInfo, nullptr, vkBuffer);
|
vk::Result r = komputeManager()->device()->createBuffer(&bufferCreateInfo, nullptr, vkBuffer);
|
||||||
if (r != vk::Result::eSuccess)
|
if (r != vk::Result::eSuccess)
|
||||||
std::cerr << "Error allocating buffer" << vk::to_string(r);
|
std::cerr << "Error allocating buffer " << vk::to_string(r) << std::endl;
|
||||||
return vkBuffer;
|
return vkBuffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -358,8 +358,10 @@ vk::DeviceMemory *ggml_vk_allocate(size_t size, vk::MemoryPropertyFlags flags, v
|
|||||||
allocInfo.memoryTypeIndex = memoryTypeIndex;
|
allocInfo.memoryTypeIndex = memoryTypeIndex;
|
||||||
vk::DeviceMemory *vkDeviceMemory = new vk::DeviceMemory;
|
vk::DeviceMemory *vkDeviceMemory = new vk::DeviceMemory;
|
||||||
vk::Result r = komputeManager()->device()->allocateMemory(&allocInfo, nullptr, vkDeviceMemory);
|
vk::Result r = komputeManager()->device()->allocateMemory(&allocInfo, nullptr, vkDeviceMemory);
|
||||||
if (r != vk::Result::eSuccess)
|
if (r != vk::Result::eSuccess) {
|
||||||
std::cerr << "Error allocating memory" << vk::to_string(r);
|
std::cerr << "Error allocating memory " << vk::to_string(r) << std::endl;
|
||||||
|
throw std::runtime_error("Error allocating vulkan memory.");
|
||||||
|
}
|
||||||
return vkDeviceMemory;
|
return vkDeviceMemory;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user