/tensorflow-runtime-metadata-visualization

TensorFlow Runtime Tracing Metadata Visualization

Primary LanguageHTMLApache License 2.0Apache-2.0

TensorFlow Runtime Tracing Metadata Visualization

This library visualizes the runtime trace of TensorFlow.

Compare to built-in Chrome Tracing Format:

  • Retains op execution details. (e.g., RecvTensor ops source and destination)
  • Separates network ops from computing
  • Faster Navigation

Example: timeline of Inception execution is available here. Inception Timeline

How to use

  1. Collect Runtime metadata in TensorFlow:
    from tfvis import Timeline
    ...
    
    with tf.train.MonitoredTrainingSession(...) as sess:
        ...
        with Timeline() as timeline:
            sess.run(train_op, **timeline.kwargs)
        ...
  2. Visualize:
    ...
    timeline.visualize("example.html")
    ...

Frequently Asked Questions

Horovod Support?

Pass horovod=True to Timeline:

with Timeline(horovod=True) as timeline:
        sess.run(train_op, **timeline.kwargs)

Save raw runtime data?

Use this:

with Timeline(horovod=True) as timeline:
        sess.run(train_op, **timeline.kwargs)
        
timeline.to_pickle("example.pickle")
...
timeline.from_pickle("example.pickle", horovod=True)

Python 2?

It is supported experimentally, but has not been throughly tested.

Collect Runtime Metadata Natively?

Use this:

...

with tf.train.MonitoredTrainingSession(...) as sess:
	...
	run_metadata = tf.RunMetadata()
	options = tf.RunOptions(trace_level=tf.RunOptions.FULL_TRACE)
	sess.run(train_op, run_metadata=run_metadata, options=options)
...

Store:

import pickle

with open("example.pickle", "wb") as fp:
        pickle.dump(run_metadata, fp)

Load and Visualize:

    from tfvis import Timeline
    Timeline.from_pickle("example.pickle").visualize("example.html")

Cite this tool

@misc{Hashemi2018,
  author = {Sayed Hadi Hashemi},
  title = {TensorFlow Runtime Tracing Metadata Visualization},
  year = {2018},
  publisher = {GitHub},
  journal = {GitHub repository},
  howpublished = {\url{https://github.com/xldrx/tensorflow-runtime-metadata-visualization}},
}