请原谅这个问题的宽泛性。也许一旦我知道了更多,也许我可以更具体地要求。
我有性能敏感的tensorflow代码。从对gpu编程知之甚少的人的角度来看,我想知道什么指南或策略将是优化我的代码的“好起点”。(单一gpu)
也许每次花在每个tensorflow上的时间会很好.
我有个模糊的理解
可能还有其他一些我不知道的共同因素。
发布于 2016-06-12 12:49:03
关于如何使用Timeline对象来获取图形中每个节点的执行时间,我想给出一个更完整的答案:
sess.run(),但指定参数options和run_metadatarun_metadata.step_stats数据创建Timeline对象。下面是示例代码:
import tensorflow as tf
from tensorflow.python.client import timeline
x = tf.random_normal([1000, 1000])
y = tf.random_normal([1000, 1000])
res = tf.matmul(x, y)
# Run the graph with full trace option
with tf.Session() as sess:
run_options = tf.RunOptions(trace_level=tf.RunOptions.FULL_TRACE)
run_metadata = tf.RunMetadata()
sess.run(res, options=run_options, run_metadata=run_metadata)
# Create the Timeline object, and write it to a json
tl = timeline.Timeline(run_metadata.step_stats)
ctf = tl.generate_chrome_trace_format()
with open('timeline.json', 'w') as f:
f.write(ctf)然后,您可以打开Google,转到chrome://tracing页面并加载timeline.json文件。你应该做这样的事:

https://stackoverflow.com/questions/37751739
复制相似问题