Function: get_mem_info

Applicability

Product

Supported (√/x)

Atlas A3 training products/Atlas A3 inference products

Atlas A2 training products/Atlas A2 inference products

Atlas training products

Atlas inference products

Atlas 200I/500 A2 inference products

Function Usage

Obtains the free and total memory sizes of an app with specified attributes, excluding the memory size reserved for the system.

Prototype

  • C Prototype
    1
    aclError aclrtGetMemInfo(aclrtMemAttr attr, size_t *free, size_t *total)
    
  • Python Function
    1
    free, total, ret = acl.rt.get_mem_info(attr)
    

Parameter Description

Parameter

Input/Output

Description

attr

Input

Int, memory attribute to be queried. For details, see aclrtMemAttr.

Return Value Description

Return Value

Description

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: 0 on success; else, failure.

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 training products

    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 A2 training products/Atlas A2 inference products

    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 200I/500 A2 inference products

    If on-chip memory is queried, the system automatically queries the DDR memory because the device does not have on-chip memory. For example, the system queries ACL_DDR_MEM instead of ACL_HBM_MEM, and ACL_DDR_MEM_HUGE instead of ACL_HBM_MEM_HUGE.

  • Atlas inference products

    If on-chip memory is queried, the system automatically queries the DDR memory because the device does not have on-chip memory. For example, the system queries ACL_DDR_MEM instead of ACL_HBM_MEM, and ACL_DDR_MEM_HUGE instead of ACL_HBM_MEM_HUGE.

  • Atlas A3 training products/Atlas A3 inference products