mindspore.hal.memory_stats
- mindspore.hal.memory_stats(device_target=None)[source]
Returns status information queried from the memory pool.
Note
If device_target is not specified, get the device capability of the current backend set by context.
For the CPU backend, a dictionary with empty data is always returned.
- Parameters
device_target (str, optional) – The device name of backend, should be one of "CPU", "GPU" and "Ascend". Default value:
None
.- Returns
dict, the queried memory information.
Examples
>>> import mindspore as ms >>> import numpy as np >>> from mindspore import Tensor, ops >>> a = Tensor(np.ones([1, 2]), ms.float32) >>> b = Tensor(np.ones([1, 2]), ms.float32) >>> c = ops.add(a, b).asnumpy() >>> print(ms.hal.memory_stats()) {'total_reserved_memory': 1073741824, 'total_allocated_memory': 1024, 'total_idle_memory': 1073740800, 'total_eager_free_memory': 0, 'max_reserved_memory': 1073741824, 'max_allocated_memory': 1536, 'common_mem_pool_stats': {'block_unit_size': 1073741824, 'block_counts': 1, 'blocks_info': {<capsule object NULL at 0x7f7e8c27b030>: {'block_stream_id': 0, 'block_memory_size': 1073741824}}}, 'persistent_mem_pool_stats': {'block_unit_size': 1073741824, 'block_counts': 0, 'blocks_info': {}}}