#ifndef __DEVICE_UTIL__ #define __DEVICE_UTIL__ #include "acl/acl.h" #include "acl/ops/acl_dvpp.h" #include "logger.hpp" size_t GetDeviceMem(int dev_id) { aclrtSetDevice(dev_id); size_t free = 0; size_t total = 0; aclError err = aclrtGetMemInfo(ACL_DDR_MEM, &free, &total); aclrtResetDevice(dev_id); if (err != 0){ LOG_ERROR("aclrtGetMemInfo error!"); return -1; } size_t usage = (total - free)/(1024*1024); LOG_INFO("device {} memory usage/total:{}/{}", dev_id, usage, total/(1024*1024)); return usage; } #endif // __DEVICE_UTIL__