question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TensorFlow v2: Graph does not appear on TensorBoard

See original GitHub issue

A graph may not appear if TensorFlow could not trace any graph during the execution. For instance, below code does not use @tf.function and, because it is pure eager, there is no graph TensorFlow used.

# Missing @tf.function
def foo(x, y):
  return tf.linalg.cross(x, y)

tf.summary.trace_on()
foo([1,2], [3,4])
with writer.as_default():
  tf.summary.trace_export()

Other known issues

  • When a function is invoked before trace, the graph does not show up
@tf.function
def foo(x, y):
  return tf.linalg.cross(x, y)

foo([1,2], [3,4]) # this is not traced.
tf.summary.trace_on()
foo([1,2], [3,4])
with writer.as_default():
  tf.summary.trace_export()

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:23
  • Comments:42 (15 by maintainers)

github_iconTop GitHub Comments

12reactions
stephanwleecommented, Apr 16, 2019

@cottrell Yup correct. Pure eager builds no graph. Keras always has built some graph underneath (the details escape me at the moment but IIRC, in v1, it built a graph using its own session and, in v2, it constructs graph with FuncGraph) and is able to show some graph unless you pass run_eagerly to its compile method.

3reactions
luvwinniecommented, May 23, 2019

Device: macbook pro 2018 , macOS Mojave 10.14.5 tensorflow version: tensorflow==2.0.0a0 tensorflow-estimator-2.0-preview==1.14.0.dev2019052100

I have the same issues too, i followed the code shows in https://tensorflow.org/tensorboard/r2/graphs the most below method.

# The function to be traced.
@tf.function
def my_func(x, y):
  # A simple hand-rolled layer.
  return tf.nn.relu(tf.matmul(x, y))

# Set up logging.
stamp = datetime.now().strftime("%Y%m%d-%H%M%S")
logdir = 'logs/func/%s' % stamp
writer = tf.summary.create_file_writer(logdir)

# Sample data for your function.
x = tf.random.uniform((3, 3))
y = tf.random.uniform((3, 3))

# Bracket the function call with
# tf.summary.trace_on() and tf.summary.trace_export().
tf.summary.trace_on(graph=True, profiler=True)
# Call only one tf.function when tracing.
z = my_func(x, y)
with writer.as_default():
  tf.summary.trace_export(
      name="my_func_trace",
      step=0,
      profiler_outdir=logdir)

in the tutorials, it shows the graphs, however when i ran this code in my environment it doesn’t shows the graph in the tensorboard

Read more comments on GitHub >

github_iconTop Results From Across the Web

TensorFlow 2.0 - Graph not showing in TensorBoard
I'm trying to show the graph of a deep autoencoder in TensorBoard. I've called the decorator @tf.function on the function used for training, ......
Read more >
Examining the TensorFlow Graph | TensorBoard
This tutorial presents a quick overview of how to generate graph diagnostic data and visualize it in TensorBoard's Graphs dashboard. You'll ...
Read more >
Migrating tf.summary usage to TF 2.x | TensorBoard
If you are using tf.keras there may be no action you need to take to upgrade to TensorFlow 2.x.
Read more >
Debugging Numerical Issues in TensorFlow Programs Using ...
This is certainly not how the model training is expected to behave: ... The Debugger V2 GUI in TensorBoard is organized into six...
Read more >
Get started with TensorBoard - TensorFlow
The Graphs dashboard helps you visualize your model. In this case, the Keras graph of layers is shown which can help you ensure...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found