-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathvisualize.py
37 lines (26 loc) · 859 Bytes
/
visualize.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
import logging
import pickle
import sys
import fire
import matplotlib.pyplot as plt
import matplotlib.patches as patches
def visualize_memory(dict):
mem_stats = dict['mem_stats']
mem_stats = [elem/1e6 for elem in mem_stats]
start_time = min(dict['time_stamps'])
time_stamps = [elem - start_time for elem in dict['time_stamps']]
plt.style.use("ggplot")
plt.plot(time_stamps, mem_stats, label="gpu mem stats")
# plt.set_xlim([min(time_stamps), max(time_stamps)])
# axis.set_ylim([0, offset])
plt.xlabel("time/s")
plt.ylabel("memory/MB")
plt.title("gpu mem stats")
plt.savefig('memstats.png')
def visualize_profile(filename):
# load profile data
with open(filename, "rb") as f:
dict = pickle.load(f)
visualize_memory(dict)
if __name__ == "__main__":
fire.Fire(visualize_profile)