From 6ef8965c32bd4bda556b930a5b99bd9fa98df30c Mon Sep 17 00:00:00 2001 From: tanghuikang Date: Thu, 20 Oct 2022 14:39:23 +0800 Subject: [PATCH] Add meory offload doc --- .../api_python/mindspore/mindspore.set_context.rst | 6 ++++++ mindspore/python/mindspore/context.py | 11 +++++++++++ 2 files changed, 17 insertions(+) diff --git a/docs/api/api_python/mindspore/mindspore.set_context.rst b/docs/api/api_python/mindspore/mindspore.set_context.rst index 6827b848ab5..a169c161f73 100644 --- a/docs/api/api_python/mindspore/mindspore.set_context.rst +++ b/docs/api/api_python/mindspore/mindspore.set_context.rst @@ -74,6 +74,8 @@ mindspore.set_context | | support_binary | CPU/GPU/Ascend | | +------------------------------+----------------------------+ | | memory_optimize_level | CPU/GPU/Ascend | + | +------------------------------+----------------------------+ + | | memory_offload | GPU/Ascend | +-------------------------+------------------------------+----------------------------+ 参数: @@ -146,6 +148,10 @@ mindspore.set_context - O0: 执行性能优先,关闭 SOMAS (Safe Optimized Memory Allocation Solver)。 - O1: 内存性能优先,使能 SOMAS。 + - **memory_offload** (str) - 是否开启Offload功能,在内存不足场景下将空闲数据临时拷贝至Host侧内存。其值必须在['ON', 'OFF']范围中,默认值为'OFF'。 + + - ON:开启memory offload功能。在Ascend硬件平台,未设置环境变量“GRAPH_OP_RUN=1”时本参数不生效;设置memory_optimize_level='O1'时本参数不生效。 + - OFF:关闭memory offload功能。 异常: - **ValueError** - 输入key不是上下文中的属性。 diff --git a/mindspore/python/mindspore/context.py b/mindspore/python/mindspore/context.py index ce5a8a28077..bf33493a8e9 100644 --- a/mindspore/python/mindspore/context.py +++ b/mindspore/python/mindspore/context.py @@ -789,6 +789,8 @@ def set_context(**kwargs): | | support_binary | CPU/GPU/Ascend | | +------------------------------+----------------------------+ | | memory_optimize_level | CPU/GPU/Ascend | + | +------------------------------+----------------------------+ + | | memory_offload | GPU/Ascend | +-------------------------+------------------------------+----------------------------+ Args: @@ -938,6 +940,14 @@ def set_context(**kwargs): - O0: priority performance option, disable SOMAS (Safe Optimized Memory Allocation Solver). - O1: priority memory option, enable SOMAS. + memory_offload (str): Whether to enable the memory offload function. When it is enabled, the idle data will be + temporarily copied to the host side in the case of insufficient device memory. The value must be in the + range of ['ON', 'OFF'], and the default value is 'OFF'. + + - ON: Enable the memory Offload function. On Ascend hardware platform, this parameter does not take effect + when the environment variable "GRAPH_OP_RUN=1" is not set; This parameter does not take effect when + memory_optimize_level is set 'O1'. + - OFF: Turn off the memory Offload function. Raises: ValueError: If input key is not an attribute in context. @@ -968,6 +978,7 @@ def set_context(**kwargs): >>> ms.set_context(inter_op_parallel_num=4) >>> ms.set_context(disable_format_transform=True) >>> ms.set_context(memory_optimize_level='O0') + >>> ms.set_context(memory_offload='ON') """ ctx = _context() # set device target first