Function: get_mem_info

Applicable Products

Product

Supported (√/x)

Ascend 950PR/Ascend 950DT

√

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

√

Description

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)
    

Parameters

Parameter

Input/Output

Description

attr

Input

Memory attribute value to be queried. The value is of the int type. For details, see aclrtMemAttr.

Return Values

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 device for computation (for example, call acl.rt.set_device to specify the device for computation). Therefore, the device ID is not displayed 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