Function: get_mem_info

C Prototype

aclError aclrtGetMemInfo(aclrtMemAttr attr, size_t *free, size_t *total)

Python Function

free, total, ret = acl.rt.get_mem_info(attr)

Function Usage

Obtains the free and total memory sizes of a pyACL application with specified attributes, excluding the memory size reserved for the system.

Input Description

attr: int, memory attribute to be queried. For details, see aclrtMemAttr.

Return Value

free: int, free memory size of the corresponding attribute, in bytes.

total: int, total memory size of the corresponding attribute, in bytes.

ret: int, error code.

Restrictions

  • Before calling this API, you must specify the compute device (for example, calling acl.rt.set_device to specify the compute device). Therefore, the device ID is not involved in this API.
  • Atlas 200/300/500 Inference Product

    Select the memory of a specified attribute based on hardware. Otherwise, the free memory size and total memory size output by this API call are both 0.

  • Atlas Training Series Product

    Select the memory of a specified attribute based on hardware. Otherwise, the free memory size and total memory size output by this API call are both 0.