def log(self, type: str, data: dict = {}, **kwdargs): """ Add an iteration to the log with the specified data points. Type should be the type of information this is (e.g., train, valid, etc.) You can either pass data points as kwdargs, or as a dictionary (or both!). Values should be json-serializable. """ info = {} info['type'] = type info['session'] = self.session kwdargs.update(data) info['data'] = kwdargs if self.log_gpu_stats: keys = ['fan_spd', 'temp', 'pwr_used', 'mem_used', 'util'] gpus = gpu_info() info['gpus'] = [{k: gpus[i][k] for k in keys} for i in self.visible_gpus] if self.log_time: info['time'] = time.time() out = json.dumps(info) + '\n' with open(self.log_path, 'a') as f: f.write(out)
def _log_session_header(self, session_data: dict): """ Log information that does not change between iterations here. This is to cut down on the file size so you're not outputing this every iteration. """ info = {} info["type"] = "session" info["session"] = self.session info["data"] = session_data if self.log_gpu_stats: keys = ["idx", "name", "uuid", "pwr_cap", "mem_total"] gpus = gpu_info() info["gpus"] = [{k: gpus[i][k] for k in keys} for i in self.visible_gpus] if self.log_time: info["time"] = time.time() out = json.dumps(info) + "\n" with open(self.log_path, "a") as f: f.write(out)
def _log_session_header(self, session_data: dict): """ Log information that does not change between iterations here. This is to cut down on the file size so you're not outputing this every iteration. """ info = {} info['type'] = 'session' info['session'] = self.session info['data'] = session_data if self.log_gpu_stats: keys = ['idx', 'name', 'uuid', 'pwr_cap', 'mem_total'] gpus = gpu_info() info['gpus'] = [{k: gpus[i][k] for k in keys} for i in self.visible_gpus] if self.log_time: info['time'] = time.time() out = json.dumps(info) + '\n' with open(self.log_path, 'a') as f: f.write(out)
def log(self, type: str, data: dict = {}, **kwdargs): """ Add an iteration to the log with the specified data points. Type should be the type of information this is (e.g., train, valid, etc.) You can either pass data points as kwdargs, or as a dictionary (or both!). Values should be json-serializable. """ info = {} info["type"] = type info["session"] = self.session kwdargs.update(data) info["data"] = kwdargs if self.log_gpu_stats: keys = ["fan_spd", "temp", "pwr_used", "mem_used", "util"] gpus = gpu_info() info["gpus"] = [{k: gpus[i][k] for k in keys} for i in self.visible_gpus] if self.log_time: info["time"] = time.time() out = json.dumps(info) + "\n" with open(self.log_path, "a") as f: f.write(out)