Last active
September 9, 2020 08:05
-
-
Save ikhlestov/80ee9abee427b13bf9d9c5103ebb2e6e to your computer and use it in GitHub Desktop.
01_Profiling Tensorflow with timeline
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import tensorflow as tf | |
from tensorflow.python.client import timeline | |
a = tf.random_normal([2000, 5000]) | |
b = tf.random_normal([5000, 1000]) | |
res = tf.matmul(a, b) | |
with tf.Session() as sess: | |
# add additional options to trace the session execution | |
options = tf.RunOptions(trace_level=tf.RunOptions.FULL_TRACE) | |
run_metadata = tf.RunMetadata() | |
sess.run(res, options=options, run_metadata=run_metadata) | |
# Create the Timeline object, and write it to a json file | |
fetched_timeline = timeline.Timeline(run_metadata.step_stats) | |
chrome_trace = fetched_timeline.generate_chrome_trace_format() | |
with open('timeline_01.json', 'w') as f: | |
f.write(chrome_trace) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment