Skip to content

Commit

Permalink
return false when dynamic shape in check_allocatable() to aviod asser…
Browse files Browse the repository at this point in the history
…tion by big upper bound
  • Loading branch information
wilson-seok committed Apr 5, 2024
1 parent 5ca08a7 commit 00c2e66
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
17 changes: 14 additions & 3 deletions src/plugins/intel_gpu/src/runtime/ocl/ocl_engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,21 +128,32 @@ allocation_type ocl_engine::detect_usm_allocation_type(const void* memory) const
bool ocl_engine::check_allocatable(const layout& layout, allocation_type type) {
OPENVINO_ASSERT(supports_allocation(type) || type == allocation_type::cl_mem, "[GPU] Unsupported allocation type: ", type);

OPENVINO_ASSERT(layout.bytes_count() <= get_device_info().max_alloc_mem_size,
bool above_max_device_mem_size = (layout.bytes_count() > get_device_info().max_alloc_mem_size);

// When dynamic shape upper bound makes bigger buffer, then return false.
if (above_max_device_mem_size && layout.is_dynamic())
return false;

OPENVINO_ASSERT(!above_max_device_mem_size,
"[GPU] Exceeded max size of memory object allocation: ",
"requested ", layout.bytes_count(), " bytes, "
"but max alloc size supported by device is ", get_device_info().max_alloc_mem_size, " bytes.",
"Please try to reduce batch size or use lower precision.");

auto used_mem = get_used_device_memory(allocation_type::usm_device) + get_used_device_memory(allocation_type::usm_host);
auto above_max_usable_mem_size = (layout.bytes_count() + used_mem > get_max_memory_size());

// When dynamic shape upper bound makes bigger buffer, then return false.
if (above_max_usable_mem_size && layout.is_dynamic())
return false;
#ifdef __unix__
// Prevent from being killed by Ooo Killer of Linux
OPENVINO_ASSERT(layout.bytes_count() + used_mem <= get_max_memory_size(),
OPENVINO_ASSERT(!above_max_usable_mem_size,
"[GPU] Exceeded max size of memory allocation: ",
"Required ", layout.bytes_count(), " bytes, already occupied : ", used_mem, " bytes, ",
"but available memory size is ", get_max_memory_size(), " bytes");
#else
if (layout.bytes_count() + used_mem > get_max_memory_size()) {
if (above_max_usable_mem_size) {
GPU_DEBUG_COUT << "[Warning] [GPU] Exceeded max size of memory allocation: " << "Required " << layout.bytes_count() << " bytes, already occupied : "
<< used_mem << " bytes, but available memory size is " << get_max_memory_size() << " bytes" << std::endl;
GPU_DEBUG_COUT << "Please note that performance might drop due to memory swap." << std::endl;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,11 @@ const std::vector<ov::test::InputShape> inputShapes4D = {
{
{{20, 100}, 12, {1, 400}, {1, 300}},
{{30, 12, 10, 20}, {20, 12, 5, 40}}
}
},
{ // Excessive upper bound case
{3, 8, {128, 16384}, {128, 16384}},
{{3, 8, 128, 128}}
},
};

const std::vector<int64_t> axis5D = {0, 1, 2, 4};
Expand Down

0 comments on commit 00c2e66

Please sign in to comment.