Skip to content

Commit a0552c8

Browse files
authored
vulkan: Add env var to disable host visible vidmem (#15109)
1 parent 99acbc9 commit a0552c8

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -534,6 +534,7 @@ struct vk_device_struct {
534534
ggml_backend_buffer_type buffer_type;
535535

536536
bool disable_fusion;
537+
bool disable_host_visible_vidmem;
537538

538539
#ifdef GGML_VULKAN_MEMORY_DEBUG
539540
std::unique_ptr<vk_memory_logger> memory_logger;
@@ -1804,6 +1805,8 @@ static vk_buffer ggml_vk_create_buffer_device(vk_device& device, size_t size) {
18041805
} else if (device->uma) {
18051806
// Fall back to host memory type
18061807
buf = ggml_vk_create_buffer(device, size, vk::MemoryPropertyFlagBits::eDeviceLocal, vk::MemoryPropertyFlagBits::eHostVisible | vk::MemoryPropertyFlagBits::eHostCoherent);
1808+
} else if (device->disable_host_visible_vidmem) {
1809+
buf = ggml_vk_create_buffer(device, size, vk::MemoryPropertyFlagBits::eDeviceLocal, vk::MemoryPropertyFlagBits::eDeviceLocal);
18071810
} else {
18081811
// use rebar if available, otherwise fallback to device only visible memory
18091812
buf = ggml_vk_create_buffer(device, size, vk::MemoryPropertyFlagBits::eDeviceLocal | vk::MemoryPropertyFlagBits::eHostVisible | vk::MemoryPropertyFlagBits::eHostCoherent, vk::MemoryPropertyFlagBits::eDeviceLocal);
@@ -3265,6 +3268,9 @@ static vk_device ggml_vk_get_device(size_t idx) {
32653268
const char* GGML_VK_PREFER_HOST_MEMORY = getenv("GGML_VK_PREFER_HOST_MEMORY");
32663269
device->prefer_host_memory = GGML_VK_PREFER_HOST_MEMORY != nullptr;
32673270

3271+
const char* GGML_VK_DISABLE_HOST_VISIBLE_VIDMEM = getenv("GGML_VK_DISABLE_HOST_VISIBLE_VIDMEM");
3272+
device->disable_host_visible_vidmem = GGML_VK_DISABLE_HOST_VISIBLE_VIDMEM != nullptr;
3273+
32683274
bool fp16_storage = false;
32693275
bool fp16_compute = false;
32703276
bool maintenance4_support = false;

0 commit comments

Comments
 (0)