uber/neuropod

create_keras_neuropod() does not work with TF 2.6 (AttributeError: 'KerasTensor' object has no attribute 'graph')

thuningxu opened this issue · 1 comments

Bug

  File "...neuropod/backends/keras/packager.py", line 85, in create_keras_neuropod
    graph_def = model.outputs[0].graph.as_graph_def()
AttributeError: 'KerasTensor' object has no attribute 'graph'

To Reproduce

Steps to reproduce the behavior:

This is test script running with Neuropod 0.3.0rc3 and TF 2.6
https://gist.github.com/thuningxu/659c8d4ed355e5c544a2bb2eb002415b

Expected behavior

Neuropod created and inference made

Environment

  • Neuropod Version (e.g., 0.2.0): 0.3.0rc3
  • OS (Linux, macOS): Linux
  • Language (Python, C++, Go bindings): Python
  • Python version: 3.6.9
  • Using OPE: no

If this bug report is about running a specific model:

  • Neuropod backend (e.g. TensorFlow, PyTorch, Keras, TorchScript, Python): Tensorflow
  • Framework version (e.g. 1.3.0): 2.6

If running on GPU:

  • CUDA/cuDNN version: 11.4
  • The output of nvidia-smi: NVIDIA-SMI 470.63.01 Driver Version: 470.63.01 CUDA Version: 11.4

  • Any other relevant information:

Additional context

I figured out this...basically I need to call tensorflow.disable_v2_behavior() before creating the Keras model. This way the model will not have KerasTensor.