This repository was archived by the owner on Jun 5, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 137
/
Copy pathgenerate_util_graph.py
66 lines (51 loc) · 1.49 KB
/
generate_util_graph.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
# coding=utf-8
# generate cpu/gpu util graph based on the json data
import argparse
import sys
import os
import json
import matplotlib
matplotlib.use('Agg')
from matplotlib import pyplot as plt
parser = argparse.ArgumentParser()
parser.add_argument("logs")
parser.add_argument("output_png")
if __name__ == "__main__":
args = parser.parse_args()
with open(args.logs, "r") as f:
data = json.load(f)
# timing as the timestamp as the x axis, and others as y axis
# timestamp to local time in seconds
start_time = data["timing"][0]
timings = [round(o - start_time, 1) for o in data["timing"]]
# cpu and gpu util
cpu_util = [round(o, 1) for o in data["cpu_utilization"]]
gpu_util = [round(o, 1) for o in data["gpu_utilization"]]
# gpu mem and ram, in MB
ram_used = [round(o, 1) for o in data["ram_used"]]
gpu_mem = [round(o, 1) for o in data["gpu_memory"]]
# plot!
plt.figure(figsize=(10, 6))
# cpu util
plt.subplot(221)
plt.plot(timings, cpu_util, "g-")
plt.title("cpu util %")
plt.xlabel("seconds")
plt.grid(True)
plt.subplot(222)
plt.plot(timings, ram_used, "g-")
plt.title("ram used (MB)")
plt.xlabel("seconds")
plt.grid(True)
plt.subplot(223)
plt.plot(timings, gpu_util, "b-")
plt.title("gpu util %")
plt.xlabel("seconds")
plt.grid(True)
plt.subplot(224)
plt.plot(timings, gpu_mem, "b-")
plt.title("GPU mem (MB)")
plt.xlabel("seconds")
plt.grid(True)
plt.subplots_adjust(hspace=0.5, wspace=0.3)
plt.savefig(args.output_png, dpi=400)