DeviceUtil.hpp
553 Bytes
#ifndef __DEVICE_UTIL__
#define __DEVICE_UTIL__
#include "acl/acl.h"
#include "acl/ops/acl_dvpp.h"
#include "logger.hpp"
int 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;
}
LOG_INFO("device {} memory usage/total:{}/{}", dev_id, total - free, total);
return total - free;
}
#endif // __DEVICE_UTIL__