Graph visualization failed in TensorFlow2.1.0

Viewed 713

I am fresher to TensorFlow2 and I write such code to use autograph in Jupyter.
But I get Graph visualization failed error, which give a hint let me refer to tensorflow/tensorboard/issues/1961.

import tensorflow as tf

@tf.function
def strjoin(x,y):
    z =  tf.strings.join([x,y],separator = " ")
    tf.print(z)
    return z

result = strjoin(tf.constant("hello"),tf.constant("world"))

print(result)

import datetime

import os
stamp = datetime.datetime.now().strftime("%Y%m%d-%H%M%S")
logdir = os.path.join('data', 'autograph', stamp)


writer = tf.summary.create_file_writer(logdir)

tf.summary.trace_on(graph=True, profiler=True) 

result = strjoin("hello","world")

with writer.as_default():
    tf.summary.trace_export(
        name="autograph",
        step=0,
        profiler_outdir=logdir)

%load_ext tensorboard

%tensorboard --logdir ./data/autograph/

Here are the related packages versions:

tensorboard                2.1.1
tensorflow-estimator       2.1.0
tensorflow-gpu             2.1.0

It seems that TensorFlow doesn't trace any graph, but I did turn the trace on.
Could anyone help me?
Thanks in advance.

1 Answers

The problem has been resolved.

I also meet this problem and using the same code.

The problem is cause by incompatible versions between tensorboard and tensorflow you use. I created a conda virtual environment for tf2.1, then run the code above and the command tensorboard --logdir ./data/autograph/, but it seems that the Terminal use default tensorboard in root environment instead of the tf2.1 environment in using. So I tried the below command in Terminal:

conda activate tf2.1
tensorboard --logdir ./data/autograph/

After that, the tensorboard can run correctly.

Related