I'm trying to profile a Tensorflow graph in Tensorboard, but despite recording runtime metadata, the "Compute time" colour option is greyed out. A simple example as follows:
import tensorflow as tf
sess = tf.Session()
x = tf.constant(1.0)
y = tf.constant(2.0)
z = x + y
writer = tf.summary.Filewriter('logs', sess.graph)
run_options = tf.RunOptions(trace_level=tf.RunOptions.FULL_TRACE)
run_meta = tf.RunMetadata()
res = sess.run(z, options=run_options, run_metadata=run_meta)
writer.add_run_metadata(run_meta, "metadata")
writer.close()
I then run Tensorboard from the terminal:
$ tensorboard --logdir logs
I then navigate to http://localhost:6006 in Chrome, and can see the TF graph visualisation, but no performance stats. Am I missing something obvious?
Thanks,
Chris
Specs: OSX Mojave, Anaconda Python 3.6.8, Tensorflow 1.14.
Question answered! The piece I was missing was the dropdown "Tag" menu in the Tensorboard navigation panel on the left hand side of the brower window. I clicked it, and hey presto, I have "Compute Time" available to me.
Thanks all,
Chris
Related
I am a newbie and I have had some trouble in using tensorboard.
I stared Spyder in Anaconda prompt by
conda activate D:\Software\Anaconda\envs\tf
spyder
And this is my simple code in file trial.py
import tensorflow as tf
a = 2
b = 3
x = tf.add(a, b)
writer = tf.summary.create_file_writer('./graphs')
print(writer)
Then I ran this code in spyder. I opened another Anaconda prompt and added this line
conda activate D:\Software\Anaconda\envs\tf
tensorboard --logdir=D:\Dung\Maytinh\Python\graphs --port 6006
I opened my Chrome and typed: http://localhost:6006/. The result was below:
I have tried many times and I could not understand where the error was. Some guides in the internet belong to tensorflow 1 and can not suit to handle. Please help me!
This is based on the documentation
import tensorflow as tf
a = 2
b = 3
#tf.function
def func(x, y):
return tf.add(a, b)
writer = tf.summary.create_file_writer('./graphs')
tf.summary.trace_on(graph=True, profiler=True)
z = func(a, b)
with writer.as_default():
tf.summary.trace_export(
name="trace",
step=0,
profiler_outdir='./graphs')
tensorboard --logdir ./graphs
Here's the code I've written in python3.6. When I try to plot using tensorboard I see two graphs namely main and auxilary but they do not seem to correspond to my code:
import tensorflow as tf
a = tf.constant(1.0)
b = tf.constant(2.0)
c=a*b
sess=tf.Session()
writer=tf.summary.FileWriter("E:/python_prog",sess.graph)
print(sess.run(c))
writer.close()
sess.close().
I run the code in anaconda(Windows) prompt:
(tfp3.6) E:\python_prog>tensorboard --logdir="E:\python_prog"
Starting TensorBoard b'54' at http://DESKTOP-31KSN08:6006
(Press CTRL+C to quit)
I run the following code to see the graph generated.
import tensorflow as tf
logs_dir = "/home/sukriti/Desktop/GIS/new_code"
a = tf.constant(2)
b = tf.constant(3)
x = tf.add(a, b)
with tf.Session() as sess:
writer = tf.summary.FileWriter(logs_dir, sess.graph)
print sess.run(x)
writer.close()
I ran the following command
$ python demo.py
$ tensorboard --logdir="logs_dir"
Starting TensorBoard 54 at http://drsbhattac:6006 (Press CTRL+C to
quit)
Now clicking on the above link (Graph tab)I found the following message:
No graph definition files were found
Can you please help me what I am missing here?
Thanks in advance!!
Tensorboard provides runtime statistics that allow profiling of memory consumption and compute time (see Docu).
However in tensorflow v1.2.1 some of my ops were shown dashed & in orange as "unused substructure" and did not provide any information at all - no device, nor memory, nor compute time.
With the update to tensorflow v1.3 this even got worse. Now everything is a orange dashed "unused substructure"
I tried this on various bigger tensorflow projects that I need to optimize as well as on working colleagues PCs.
Am I doing something wrong or is this a bug in tensorflow / tensorboard?
Here is an minimalistic example code:
import tensorflow as tf
from tensorflow.python.client import timeline
sess = tf.InteractiveSession()
run_options = tf.RunOptions(trace_level=tf.RunOptions.FULL_TRACE)
run_metadata = tf.RunMetadata()
# create some dummy Ops for the graph
C1 = tf.constant(5)
C2 = tf.constant(3)
myOp = C1*C2 + tf.square(C2)
res = sess.run([myOp], options=run_options,run_metadata = run_metadata)
writer = tf.summary.FileWriter(logdir='tensorboard/profile_bug',graph=sess.graph)
print (res)
tl = timeline.Timeline(run_metadata.step_stats)
ctf = tl.generate_chrome_trace_format()
with open('tensorboard/timelineOfBug.json', 'w') as f:
f.write(ctf)
writer.add_run_metadata(run_metadata,"mySess")
writer.close()
sess.close()
This is an issue with some new versions of TF (seems like 1.2 and 1.3). Updating to 1.4 fixes it.
I am reading a book on Tensorflow and I find this code:
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import tensorflow as tf
const1 = tf.constant(2)
const2 = tf.constant(3)
add_opp = tf.add(const1,const2)
mul_opp = tf.mul(add_opp, const2)
with tf.Session() as sess:
result, result2 = sess.run([mul_opp,add_opp])
print(result)
print(result2)
tf.train.SummaryWriter('./',sess.graph)
so it is very simple, nothing fancy and it is supposed to produce some output that can be visualized with tensorboard.
So I run the script, it prints the results but apparently SummaryWriter produces nothing.
I run tensorboard -logdir='./' and of course there is no graph.
What could I be doing wrong?
And also how do you terminate tensorboard? I tried ctrl-C and ctrl-Z and it does not work. (also I am in a japanese keyboard so there is no backslash just in case)
The tf.train.SummaryWriter must be closed (or flushed) in order to ensure that data, including the graph, have been written to it. The following modification to your program should work:
writer = tf.train.SummaryWriter('./', sess.graph)
writer.close()
A very wierd thing happened to me
I am learning to work with tensorflow
import tensorflow as tf
a = tf.constant(3)
b = tf.constant(4)
c = a+b
with tf.Session() as sess:
File_Writer = tf.summary.FileWriter('/home/theredcap/Documents/CS/Personal/Projects/Test/tensorflow/tensorboard/' , sess.graph )
print(sess.run(c))
Inorder to see the graph on tensorboard
I typed
tensorboard --logdir = "the above mentioned path"
But nothing was displayed on the tensorboard
Then I went to the github README page
https://github.com/tensorflow/tensorboard/blob/master/README.md
And it said to run the command in this manner
tensorboard --logdir path/to/logs
I did the same, and finally I was able to view my graph