tensorflow / tensorflow

An Open Source Machine Learning Framework for Everyone
https://tensorflow.org
Apache License 2.0
185.76k stars 74.21k forks source link

No default summary writer available when using tf.py_function with autograph #38772

Open sumanthratna opened 4 years ago

sumanthratna commented 4 years ago

System information

Describe the current behavior Using tf.summary returns False inside a tf.py_function when using autograph.

Describe the expected behavior tf.summary should return True.

Standalone code to reproduce the issue

import tensorflow as tf

@tf.function
def eager_pyfunc():
    def inner_func():
        bool_out = tf.summary.scalar('myscalar', tf.constant(32.9))
        tf.print(bool_out, name='log-myscalar-success')

    tf.py_function(inner_func, [], [], name='log-myscalar')

    bool_out2 = tf.summary.scalar('myscalar2', tf.constant(52.3))
    tf.print(bool_out2, name='log-myscalar2-success')

with tf.summary.create_file_writer('./logs').as_default():
    tf.summary.experimental.set_step(0)
    eager_pyfunc()

outputs:

0
1

Removing the tf.function outputs:

1
1

Other info / logs Could be related to https://github.com/tensorflow/tensorflow/issues/26409.

ravikyram commented 4 years ago

I have tried on colab with TF version 2.1.0, 2.2.0-rc3 and was able to reproduce the issue.Please, find the gist here.Thanks!

sushreebarsa commented 3 years ago

Was able to reproduce the issue in TF 2.14.0-dev20230514,please find the gist here..Thanks !

Venkat6871 commented 1 month ago

Hi,

Thank you for opening this issue. Since this issue has been open for a long time, the code/debug information for this issue may not be relevant with the current state of the code base.

The Tensorflow team is constantly improving the framework by fixing bugs and adding new features. We suggest you try the latest TensorFlow version with the latest compatible hardware configuration which could potentially resolve the issue. If you are still facing the issue, please create a new GitHub issue with your latest findings, with all the debugging information which could help us investigate.

Please follow the release notes to stay up to date with the latest developments which are happening in the Tensorflow space.

sumanthratna commented 1 month ago

I re-ran my minimal reproduction sample and this issue still exists on the latest stable TensorFlow.