-
Notifications
You must be signed in to change notification settings - Fork 3
/
process_err.py
134 lines (127 loc) · 3.87 KB
/
process_err.py
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
#This script is used to profile totoal buffer memory in Tensor allocation and Buffer allication
import re
import matplotlib.pyplot as plt
filepath = './err.txt'
with open(filepath) as fp:
content = fp.readlines()
content = [x.strip() for x in content]
ct1=0
ct2=0
ct3=0
ct4=0
ct5=0
ct6=0
cct=0
mct=0
dt=0
eff_ct=0
bufaloc=0
bufdealoc=0
cur_buf=0
buf_status = []
mem_status = []
number = []
time = 0
time_base = 0
time_axis = []
flag = 0
#to profile memory footprint
buf_mem=[]
tensor_buf_mem=[]
for item in content:
if "[Peng]tensorflow/core/framework/tensor.cc:Buffer()" in item:
bufaloc = bufaloc + 1
cur_buf = cur_buf + 1
number = re.findall(r'\d+',item)
#The useful memory footprint information is in number[9]
if (flag==0):
time_base = (int(number[4])*60+int(number[5]))*1000000+int(number[6])
time = 0
flag = 1
else:
time = (int(number[4])*60+int(number[5]))*1000000+int(number[6]) - time_base
buf_mem.append(int(number[9]))
if "[Peng]tensorflow/core/framework/tensor.cc:~Buffer()" in item:
bufdealoc = bufdealoc + 1
cur_buf = cur_buf - 1
number = re.findall(r'\d+',item)
#The useful memory footprint information is in number[9]
if (flag==0):
time_base = (int(number[4])*60+int(number[5]))*1000000+int(number[6])
time = 0
flag = 1
else:
time = (int(number[4])*60+int(number[5]))*1000000+int(number[6]) - time_base
buf_mem.append(int(number[8]))
elif "Tensor constructor 2" in item:
ct2 = ct2 + 1
eff_ct = eff_ct + 1
number = re.findall(r'\d+',item)
#The useful memory footprint information is in number[9]
if (flag==0):
time_base = (int(number[4])*60+int(number[5]))*1000000+int(number[6])
time = 0
flag = 1
else:
time = (int(number[4])*60+int(number[5]))*1000000+int(number[6]) - time_base
tensor_buf_mem.append(int(number[9]))
elif "Tensor constructor 3" in item:
ct3 = ct3 + 1
eff_ct = eff_ct + 1
number = re.findall(r'\d+',item)
if (flag==0):
time_base = (int(number[4])*60+int(number[5]))*1000000+int(number[6])
time = 0
flag = 1
else:
time = (int(number[4])*60+int(number[5]))*1000000+int(number[6]) - time_base
tensor_buf_mem.append(int(number[9]))
elif "Tensor constructor 4" in item:
ct4 = ct4 + 1
eff_ct = eff_ct + 1
number = re.findall(r'\d+',item)
if (flag==0):
time_base = (int(number[4])*60+int(number[5]))*1000000+int(number[6])
time = 0
flag = 1
else:
time = (int(number[4])*60+int(number[5]))*1000000+int(number[6]) - time_base
tensor_buf_mem.append(int(number[9]))
elif "Tensor constructor 5" in item:
ct5 = ct5 + 1
eff_ct = eff_ct + 1
number = re.findall(r'\d+',item)
if (flag==0):
time_base = (int(number[4])*60+int(number[5]))*1000000+int(number[6])
time = 0
flag = 1
else:
time = (int(number[4])*60+int(number[5]))*1000000+int(number[6]) - time_base
tensor_buf_mem.append(int(number[9]))
elif "[Peng]tensorflow/core/framework/tensor.cc:Tensor deconstructor" in item:
number = re.findall(r'\d+',item)
if (flag==0):
time_base = (int(number[4])*60+int(number[5]))*1000000+int(number[6])
time = 0
flag = 1
else:
time = (int(number[4])*60+int(number[5]))*1000000+int(number[6]) - time_base
tensor_buf_mem.append(int(number[8]))
mem_status.append(eff_ct)
time_axis.append(time)
buf_status.append(cur_buf)
tensor_buf_mem = [x/(1024*1024) for x in tensor_buf_mem]
plt.plot(tensor_buf_mem)
plt.ylabel('Buffer Memory (MB)')
plt.xlabel('step')
#plt.plot(buf_mem)
plt.show()
#plt.plot(time_axis,mem_status)
#plt.plot(time_axis,buf_status)
#plt.ylabel('Number of Tensor (blue) / Buffer (green)')
#plt.xlabel('step')
#plt.show()
#print "constructor 2 = " + str(ct2)
#print "constructor 3 = " + str(ct3)
#print "constructor 4 = " + str(ct4)
#print "constructor 5 = " + str(ct5)