In [1]:
import pandas
import json
import matplotlib as mpl
from matplotlib import pyplot as plt
import numpy as np
import os
import sys
%matplotlib inline
plt.style.use('bmh')
plt.style.use('dark_background')
#sys.path.append("./../sysinfo")
#from cute_device import get_cute_device_str
from helpers import read_df_from_dir, filter_by
In [2]:
#path="/work/alex/data/DL_perf/json/"
path="../../logs/2017.11/"
In [3]:
def autolabel(rects,ax):
"""
Attach a text label above each bar displaying its height
"""
max_height=200
for rect in rects:
height = rect.get_height()
if height<15:
ax.text(rect.get_x() + rect.get_width()/2., 1.05*height, '{:.2f}'.format(height), ha='center', va='bottom', fontsize=14)
if height>max_height:
ax.text(rect.get_x() + rect.get_width()/2., 1.05*max_height, '{:.2f}'.format(height), ha='center', va='bottom', fontsize=14, color="red")
In [4]:
def read_file(filename):
with open(filename) as f:
data = json.load(f)
return data
#data=read_file("../logs/scaling/conv2d_2_chainer_GeForce GTX 980 Ti_17.06.10_17.33.42.json")
In [5]:
data = [f for f in os.listdir(path) if os.path.isfile(os.path.join(path,f)) and not f.startswith("arch") ]
#df = pandas.DataFrame(data)
#df
data
Out[5]:
In [6]:
df = read_df_from_dir(path)
In [7]:
df
Out[7]:
In [ ]:
In [8]:
#df.sort_values(by=["device","framework"],inplace=True)
#df.sort_values(by=["time"],inplace=True)
In [9]:
#filter what to plot
devices=df["device"].unique()
print(devices)
#df
In [ ]:
In [10]:
#df_filtered = filter_by(df,filters={"device":"P100-PCIE"})
In [11]:
def render(key,filters,color):
id_dev=0
df_filtered = filter_by(df,filters)
df_plot=df_filtered.groupby([key],as_index=False).mean()
if df_plot.shape[0]<1:
return "nothing to plot"
df_plot.reset_index()
df_plot.sort_values(by=["time"],inplace=True, ascending=False)
mpl.rcParams['figure.figsize'] = 12, 5
ax = plt.subplot('111')#, facecolor='white')
width=0.5
#ax.set_ylim(0,200)
err = df_filtered.groupby([key])["time"].std()
#print (err)
error_config = {'ecolor': 'r'}
bars = plt.bar(np.arange(len(df_plot))+width/2,df_plot["time"],width=width,color=color, yerr=err, error_kw=error_config)
autolabel(bars,ax)
plt.ylabel("epoch time, s",size=18)
plt.xticks(np.arange(len(df_plot))+0.25)
plt.yticks(size=18)
#ax.set_xticks(np.arange(len(labels))+(width*cnt_models)/2, minor=False)
#ax.set_xticklabels(df["device"], minor=False,size=18,rotation=0)
ax.set_xticklabels(df_plot[key], minor=False,size=18,rotation=0)
plt.grid(b=False, which='major', axis='x', )
plt.tick_params(axis='x', which='both', bottom='off', top='off', labelbottom='on')
plt.tick_params(axis='y', which='both', left='off', right='off')
name_out=""
title = ""
for key in filters:
name_out+=str(filters[key])+"_"
title+=str(filters[key])+" "
name_out = name_out[:-1]
plt.title(title[:-1])
print(name_out)
plt.savefig(os.path.join("./plots",name_out+".svg"),bbox_inches="tight",transparent=True)
plt.show()
#todo: time per byte
In [12]:
#render(key="framework",filters={"device":"P100-PCIE","problem":"conv2d_1"},color="yellowgreen")
filters={"framework":"chainer","problem":"conv2d_2","nb_gpus":1}
render(key="device",filters=filters,color="yellowgreen")
In [15]:
# color=["dodgerblue","yellowgreen"][id_dev]
for problem in df["problem"].unique():
#render(key="framework",filters={"device":"E5-2699","problem":problem},color="dodgerblue")
render(key="framework",filters={"nb_gpus":1, "device":"P100-SXM2","problem":problem}, color="yellowgreen")
In [14]:
for problem in df["problem"].unique():
render(key="device",filters={"problem":problem,"framework":"chainer"},color="yellowgreen")
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]: