Commit 2662b387 authored by Your Name's avatar Your Name

timeline test

parent be1a3205
...@@ -10,6 +10,7 @@ import os ...@@ -10,6 +10,7 @@ import os
import json import json
from datetime import date, timedelta from datetime import date, timedelta
import tensorflow as tf import tensorflow as tf
from tensorflow.python.client import timeline
import subprocess import subprocess
import time import time
import glob import glob
...@@ -338,7 +339,9 @@ def main(_): ...@@ -338,7 +339,9 @@ def main(_):
"ctr_task_wgt":FLAGS.ctr_task_wgt "ctr_task_wgt":FLAGS.ctr_task_wgt
} }
config = tf.estimator.RunConfig().replace(session_config = tf.ConfigProto(device_count={'GPU':0, 'CPU':FLAGS.num_threads}), config = tf.estimator.RunConfig().replace(session_config = tf.ConfigProto(device_count={'GPU':0, 'CPU':FLAGS.num_threads}),
log_step_count_steps=FLAGS.log_steps, save_summary_steps=FLAGS.log_steps) log_step_count_steps=FLAGS.log_steps, save_summary_steps=FLAGS.log_steps, graph_options=tf.GraphOptions(
optimizer_options=tf.OptimizerOptions(opt_level=tf.OptimizerOptions.L0)))
Estimator = tf.estimator.Estimator(model_fn=model_fn, model_dir=FLAGS.model_dir, params=model_params, config=config) Estimator = tf.estimator.Estimator(model_fn=model_fn, model_dir=FLAGS.model_dir, params=model_params, config=config)
if FLAGS.task_type == 'train': if FLAGS.task_type == 'train':
...@@ -363,7 +366,13 @@ def main(_): ...@@ -363,7 +366,13 @@ def main(_):
if __name__ == "__main__": if __name__ == "__main__":
b = time.time() b = time.time()
path = "hdfs://172.16.32.4:8020/strategy/esmm/" path = "hdfs://172.16.32.4:8020/strategy/esmm/"
ptions = tf.RunOptions(trace_level=tf.RunOptions.FULL_TRACE)
run_metadata = tf.RunMetadata()
tf.logging.set_verbosity(tf.logging.INFO) tf.logging.set_verbosity(tf.logging.INFO)
tf.app.run() tf.app.run(options=ptions, run_metadata=run_metadata)
tl = timeline.Timeline(run_metadata.step_stats)
ctf = tl.generate_chrome_trace_format()
with open(FLAGS.local_dir +'timeline.json', 'w') as wd:
wd.write(ctf)
print("耗时(分钟):") print("耗时(分钟):")
print((time.time()-b)/60) print((time.time()-b)/60)
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment