2017-10-07 84 views
0

我有旨在幫助TensorFlow程序我非正式基準我用的,更重要的是,瞭解分析工具來與TensorFlow一個GPU。代碼沒有什麼,但設置了兩個佔位符的矩陣,和MATMUL運算,然後調用會話來填充佔位符和執行圖形十倍。Tensorflow時間軸元回來的NaN

下面是代碼:當我看tensorboard圖

n = 10240 
iter = 10 

tf.reset_default_graph() 
graph = tf.Graph() 
with graph.as_default(): 
    with tf.device("/gpu:0"): 
     matrix1 = tf.placeholder(tf.float32, [n, n], name="Matrix_One") 
     matrix2 = tf.placeholder(tf.float32, [n, n], name="Matrix_Two") 
     product = tf.matmul(matrix1, matrix2, name = "Matrix_Multiply") 

date = datetime.now() 
cwd = os.getcwd() 
LogBase = cwd + "/benchmarks2/" 
LogPath = LogBase + date.strftime("%Y%m%d-%H%M%S") + "/" 
print(LogPath) 

with tf.Session(graph=graph) as session: 
    tf.global_variables_initializer().run() 

    run_options = tf.RunOptions(trace_level=tf.RunOptions.FULL_TRACE) 
    run_metadata = tf.RunMetadata() 

    writer = tf.summary.FileWriter(LogPath, session.graph) 
    for i in range(iter): 
     m1 = np.random.rand(n, n) 
     m2 = np.random.rand(n, n) 
     feed_dict = { matrix1 : m1,matrix2 : m2} 
     p = session.run([product], feed_dict=feed_dict, options=run_options, run_metadata=run_metadata) 
     writer.add_run_metadata(run_metadata, 'step%2d' % i) 

    tf.summary.FileWriter(LogPath, graph).close() 

兩個特點出現:

  • 注意,我跑十次迭代,但tensorboard只顯示八個步驟,這似乎奇
  • 最重要的是,我從來沒有看到任何東西,但對於NaN的計算時間或內存,如下圖所示。注意選擇了矩陣倍數操作。

爲什麼會這樣,我怎麼能解決這個問題? enter image description here

回答

0

您是否嘗試過使用谷歌網頁跟蹤框架?這是分析計算和內存使用時間表的先前方法。

這不是一個回答你的問題,但它是比較和可能找出問題的好辦法。