01b357d4
Hu Chunming
添加获取显存占用的代码
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
#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__
|