tensorflow / addons

Useful extra functionality for TensorFlow 2.x maintained by SIG-addons
Apache License 2.0
1.69k stars 610 forks source link

Eager execution mode is disable in newer tf-gpu version #2838

Open nikhilcms opened 1 year ago

nikhilcms commented 1 year ago

System information

Describe the bug

I am running tensorflow training code inside docker container, for this I am using tensorflow/tensorflow:2.9.2-gpu image as base image and install tensorflow-addons==0.18.0, but as I interpreting correctly recent tensorflow-gpu not support enable eager execution mode that why I am not able to run tfa.image.random_cutout method.

while running image = tfa.image.random_cutout(tf.expand_dims(image, axis=0), mask_size=10, constant_values=0) line code throw below error while execustion of if tf.rank(mask_size) == 0: line:

OperatorNotAllowedInGraphError: Using a symbolic tf.Tensor as a Python bool is not allowed in Graph execution. Use Eager execution or decorate this function with @tf.function.

this error basically tell us to run above code with enable eager execution code, I have tried tf.compat.v1.enable_eager_execution() and tf.config.run_functions_eagerly(True) to enagle eager execution model but still tf.executing_eagerly() showing False

Is there any way to run tfa.image.random_cutout code with tf.executing_eagerly()=False mode ? please let me know if you need any other information.

Thanks