Skip to content

OpenVINO™ is an open source toolkit for optimizing and deploying AI inference

[GPU] Added max_alloc_mem_size property to api (#31733)

Roman Lyamine93e7585b095
diff --git a/docs/articles_en/openvino-workflow/running-inference/inference-devices-and-modes/gpu-device.rst b/docs/articles_en/openvino-workflow/running-inference/inference-devices-and-modes/gpu-device.rst
index 1462eb7efe2..7dec9df8fb7 100644
--- a/docs/articles_en/openvino-workflow/running-inference/inference-devices-and-modes/gpu-device.rst
+++ b/docs/articles_en/openvino-workflow/running-inference/inference-devices-and-modes/gpu-device.rst
@@ -450,6 +450,7 @@ Read-only Properties
- ``ov::device::type``
- ``ov::device::uuid``
- ``ov::intel_gpu::device_total_mem_size``
+- ``ov::intel_gpu::device_max_alloc_mem_size``
- ``ov::intel_gpu::execution_units_count``
- ``ov::intel_gpu::memory_statistics``
- ``ov::intel_gpu::uarch_version``
diff --git a/src/bindings/python/src/pyopenvino/core/properties/properties.cpp b/src/bindings/python/src/pyopenvino/core/properties/properties.cpp
index c7b8225d88d..5d194946bde 100644
--- a/src/bindings/python/src/pyopenvino/core/properties/properties.cpp
+++ b/src/bindings/python/src/pyopenvino/core/properties/properties.cpp
@@ -118,6 +118,7 @@ void regmodule_properties(py::module m) {
m_properties.def_submodule("intel_gpu", "openvino.properties.intel_gpu submodule that simulates ov::intel_gpu");
wrap_property_RO(m_intel_gpu, ov::intel_gpu::device_total_mem_size, "device_total_mem_size");
+ wrap_property_RO(m_intel_gpu, ov::intel_gpu::device_max_alloc_mem_size, "device_max_alloc_mem_size");
wrap_property_RO(m_intel_gpu, ov::intel_gpu::uarch_version, "uarch_version");
wrap_property_RO(m_intel_gpu, ov::intel_gpu::execution_units_count, "execution_units_count");
wrap_property_RO(m_intel_gpu, ov::intel_gpu::memory_statistics, "memory_statistics");
diff --git a/src/bindings/python/tests/test_runtime/test_properties.py b/src/bindings/python/tests/test_runtime/test_properties.py
index d2df1f65d5f..266c8690b78 100644
--- a/src/bindings/python/tests/test_runtime/test_properties.py
+++ b/src/bindings/python/tests/test_runtime/test_properties.py
@@ -188,6 +188,7 @@ def test_conflicting_enum(proxy_enums, expected_values):
(device.luid, "DEVICE_LUID"),
(device.capabilities, "OPTIMIZATION_CAPABILITIES"),
(intel_gpu.device_total_mem_size, "GPU_DEVICE_TOTAL_MEM_SIZE"),
+ (intel_gpu.device_max_alloc_mem_size, "GPU_DEVICE_MAX_ALLOC_MEM_SIZE"),
(intel_gpu.uarch_version, "GPU_UARCH_VERSION"),
(intel_gpu.execution_units_count, "GPU_EXECUTION_UNITS_COUNT"),
(intel_gpu.memory_statistics, "GPU_MEMORY_STATISTICS"),
diff --git a/src/inference/include/openvino/runtime/intel_gpu/properties.hpp b/src/inference/include/openvino/runtime/intel_gpu/properties.hpp
index 1533120e653..978259b5688 100644
--- a/src/inference/include/openvino/runtime/intel_gpu/properties.hpp
+++ b/src/inference/include/openvino/runtime/intel_gpu/properties.hpp
@@ -32,6 +32,12 @@ namespace intel_gpu {
*/
static constexpr Property<uint64_t, PropertyMutability::RO> device_total_mem_size{"GPU_DEVICE_TOTAL_MEM_SIZE"};
+/**
+ * @brief Read-only property which defines max size of memory object allocation in bytes
+ * @ingroup ov_runtime_ocl_gpu_prop_cpp_api
+ */
+static constexpr Property<uint64_t, PropertyMutability::RO> device_max_alloc_mem_size{"GPU_DEVICE_MAX_ALLOC_MEM_SIZE"};
+
/**
* @brief Read-only property to get microarchitecture identifier in major.minor.revision format
* @ingroup ov_runtime_ocl_gpu_prop_cpp_api
diff --git a/src/plugins/intel_gpu/src/plugin/plugin.cpp b/src/plugins/intel_gpu/src/plugin/plugin.cpp
index 25920c9c83b..7c6ddf393a0 100644
--- a/src/plugins/intel_gpu/src/plugin/plugin.cpp
+++ b/src/plugins/intel_gpu/src/plugin/plugin.cpp
@@ -89,8 +89,8 @@ std::string Plugin::get_device_id(const ov::AnyMap& config) const {
bool Plugin::is_weightless_cache_attributes_set(const std::shared_ptr<const ov::Model>& model) const {
const auto& type_info = ov::WeightlessCacheAttribute::get_type_info_static();
-
- for (const auto& node : model->get_ordered_ops()) {
+
+ for (const auto& node : model->get_ordered_ops()) {
if (ov::op::util::is_constant(node)) {
auto& rtInfo = node->get_rt_info();
const auto& it = rtInfo.find(type_info);
@@ -106,10 +106,10 @@ bool Plugin::is_weightless_cache_attributes_set(const std::shared_ptr<const ov::
void Plugin::set_weightless_cache_attributes(const std::shared_ptr<const ov::Model>& model) const {
uint32_t offset = 0;
const auto& type_info = ov::WeightlessCacheAttribute::get_type_info_static();
-
+
for (const auto& node : model->get_ordered_ops()) {
if (ov::op::util::is_constant(node)) {
- auto& rtInfo = node->get_rt_info();
+ auto& rtInfo = node->get_rt_info();
// Offset behaves as a unique key for each constant. Size = 1 is used as dummy.
rtInfo[type_info] = ov::WeightlessCacheAttribute(1, offset++, node->get_element_type());
@@ -119,11 +119,11 @@ void Plugin::set_weightless_cache_attributes(const std::shared_ptr<const ov::Mod
void Plugin::create_weightless_cache_attributes(const std::shared_ptr<const ov::Model>& model, ExecutionConfig& config) const {
uint32_t offset = 0;
-
+
std::shared_ptr<GpuWeightlessCacheMap>cache_attr_map = std::make_shared<GpuWeightlessCacheMap>();
for (const auto& node : model->get_ordered_ops()) {
- if (ov::op::util::is_constant(node)) {
+ if (ov::op::util::is_constant(node)) {
// Offset behaves as a unique key for each constant. Size = 1 is used as dummy.
cache_attr_map->emplace(node->get_instance_id(), ov::WeightlessCacheAttribute(1, offset++, node->get_element_type()));
}
@@ -421,10 +421,10 @@ std::shared_ptr<ov::ICompiledModel> Plugin::import_model(std::istream& model,
if (!ov::util::validate_weights_path(weights_path)) {
// This is non IR case, e.g. onnxruntime.
// This may not be required. Constant nodes should have the information already.
- // This is a temporary solution. A more robust solution will be implemented in future.
-
- // If some app modifies ov::Model before compile_model(), and
- // the constants are changed, and such modification is not done before import_model(),
+ // This is a temporary solution. A more robust solution will be implemented in future.
+
+ // If some app modifies ov::Model before compile_model(), and
+ // the constants are changed, and such modification is not done before import_model(),
// weightless caching will not produce correct result.
if (auto& orig_model = config.get_model(); orig_model != nullptr) {
if (!is_weightless_cache_attributes_set(orig_model)) {
@@ -575,6 +575,8 @@ ov::Any Plugin::get_metric(const std::string& name, const ov::AnyMap& options) c
if (name == ov::intel_gpu::device_total_mem_size) {
return decltype(ov::intel_gpu::device_total_mem_size)::value_type {device_info.max_global_mem_size};
+ } else if (name == ov::intel_gpu::device_max_alloc_mem_size) {
+ return decltype(ov::intel_gpu::device_max_alloc_mem_size)::value_type {device_info.max_alloc_mem_size};
} else if (name == ov::device::type) {
auto dev_type = device_info.dev_type == cldnn::device_type::discrete_gpu ? ov::device::Type::DISCRETE : ov::device::Type::INTEGRATED;
return decltype(ov::device::type)::value_type {dev_type};
@@ -697,6 +699,7 @@ std::vector<ov::PropertyName> Plugin::get_supported_properties() const {
ov::PropertyName{ov::device::pci_info.name(), PropertyMutability::RO},
ov::PropertyName{ov::intel_gpu::device_id.name(), PropertyMutability::RO},
ov::PropertyName{ov::intel_gpu::device_total_mem_size.name(), PropertyMutability::RO},
+ ov::PropertyName{ov::intel_gpu::device_max_alloc_mem_size.name(), PropertyMutability::RO},
ov::PropertyName{ov::intel_gpu::uarch_version.name(), PropertyMutability::RO},
ov::PropertyName{ov::intel_gpu::execution_units_count.name(), PropertyMutability::RO},
ov::PropertyName{ov::intel_gpu::memory_statistics.name(), PropertyMutability::RO},