Git Product home page Git Product logo

Comments (9)

HudsonGraeme avatar HudsonGraeme commented on June 2, 2024 2

Seeing the same issue on my side after upgrading to tf 2.16.1 from 2.15, with tf2onnx 1.16.1 I can confirm that using model.output_names = ['output'] is a workaround.

However, I later hit another issue similar to this one; tensorflow/tensorflow#63867

I am also running into the same problem. model.output_names = ['output'] fixed the first error, and led to the error you linked.

from tensorflow-onnx.

anliec avatar anliec commented on June 2, 2024 1

Seeing the same issue on my side after upgrading to tf 2.16.1 from 2.15, with tf2onnx 1.16.1
I can confirm that using model.output_names = ['output'] is a workaround.

However, I later hit another issue similar to this one; tensorflow/tensorflow#63867

from tensorflow-onnx.

LaurentBerger avatar LaurentBerger commented on June 2, 2024

I solved my problem :

model.output_names=['output']

and error vanished...
Where is it written in manual?

from tensorflow-onnx.

fatcat-z avatar fatcat-z commented on June 2, 2024

Calling code below, it works well without errors you mentioned. So I'm wondering if output_names are lost after calling model.fit(). Could you please check it?

model = my_model_cnn()

input_signature = [tf.TensorSpec(model.inputs[0].shape, model.inputs[0].dtype, name='digit')]
onnx_model, _ = tf2onnx.convert.from_keras(model, input_signature, opset=13)

from tensorflow-onnx.

LaurentBerger avatar LaurentBerger commented on June 2, 2024

Ok I Changed my code. Now I wrote


    model = my_model_cnn()
    model_name = "mymnist_cnn"
    input_signature = [tf.TensorSpec(model.inputs[0].shape, model.inputs[0].dtype, name='digit')]
    # model.output_names=['output']
    onnx_model, _ = tf2onnx.convert.from_keras(model, input_signature, opset=13)
    onnx.save(onnx_model, model_name + ".onnx")
    model.compile(optimizer='adam',loss=tf.keras.losses.categorical_crossentropy,metrics=['CategoricalAccuracy'])
....

    historique = model.fit(train_dataset,steps_per_epoch=69000 // BATCH_SIZE -1,
                           epochs=num_epochs+epoch_save,
                           initial_epoch = epoch_save,
                           validation_data=test_dataset,
                           callbacks=[tensorboard_callback, checkpoint_callback])

There is still an error :

2024-03-21 06:56:44.746665: I tensorflow/core/util/port.cc:113] oneDNN custom operations are on. You may see slightly different numerical results due to floating-point round-off errors from different computation orders. To turn them off, set the environment variable `TF_ENABLE_ONEDNN_OPTS=0`.
2024-03-21 06:56:45.100064: I tensorflow/core/util/port.cc:113] oneDNN custom operations are on. You may see slightly different numerical results due to floating-point round-off errors from different computation orders. To turn them off, set the environment variable `TF_ENABLE_ONEDNN_OPTS=0`.
WARNING:tensorflow:From C:\Users\laurent\AppData\Roaming\Python\Python310\site-packages\tf2onnx\tf_loader.py:68: The name tf.reset_default_graph is deprecated. Please use tf.compat.v1.reset_default_graph instead.

WARNING:tensorflow:From C:\Users\laurent\AppData\Roaming\Python\Python310\site-packages\tf2onnx\tf_loader.py:72: The name tf.train.import_meta_graph is deprecated. Please use tf.compat.v1.train.import_meta_graph instead.

2024-03-21 06:56:46.739390: I tensorflow/core/platform/cpu_feature_guard.cc:210] This TensorFlow binary is optimized to use available CPU instructions in performance-critical operations.
To enable the following instructions: AVX2 AVX_VNNI FMA, in other operations, rebuild TensorFlow with the appropriate compiler flags.
Traceback (most recent call last):
  File "C:\data\mnist\create_dataset_tf2.py", line 175, in <module>
    onnx_model, _ = tf2onnx.convert.from_keras(model, input_signature, opset=13)
  File "C:\Users\laurent\AppData\Roaming\Python\Python310\site-packages\tf2onnx\convert.py", line 442, in from_keras
    old_out_names = _rename_duplicate_keras_model_names(model)
  File "C:\Users\laurent\AppData\Roaming\Python\Python310\site-packages\tf2onnx\convert.py", line 331, in _rename_duplicate_keras_model_names
    if model.output_names and len(set(model.output_names)) != len(model.output_names):
AttributeError: 'Sequential' object has no attribute 'output_names'. Did you mean: 'output_shape'?


but now I note this warning (sorry I did not post all error message previously)

WARNING:tensorflow:From C:\Users\laurent\AppData\Roaming\Python\Python310\site-packages\tf2onnx\tf_loader.py:72: The name tf.train.import_meta_graph is deprecated. Please use tf.compat.v1.train.import_meta_graph instead.

I work on windows so i use same code with WSL2 no warning and no error model is saved with new code but it is

tensorflow 2.15.1
tensorflow-addons 0.22.0
tensorflow-datasets 4.9.3
tensorflow-estimator 2.15.0
tensorflow-io-gcs-filesystem 0.32.0
tensorflow-metadata 1.14.0
tensorrt 8.5.3.1

tf2onnx 1.16.1
onnx 1.14.0
onnxruntime 1.15.1
onnxsim 0.4.33

python3 create_dataset_tf2.py
2024-03-21 07:00:44.449223: I tensorflow/core/util/port.cc:113] oneDNN custom operations are on. You may see slightly different numerical results due to floating-point round-off errors from different computation orders. To turn them off, set the environment variable `TF_ENABLE_ONEDNN_OPTS=0`.
2024-03-21 07:00:44.467172: E external/local_xla/xla/stream_executor/cuda/cuda_dnn.cc:9261] Unable to register cuDNN factory: Attempting to register factory for plugin cuDNN when one has already been registered
2024-03-21 07:00:44.467207: E external/local_xla/xla/stream_executor/cuda/cuda_fft.cc:607] Unable to register cuFFT factory: Attempting to register factory for plugin cuFFT when one has already been registered
2024-03-21 07:00:44.467680: E external/local_xla/xla/stream_executor/cuda/cuda_blas.cc:1515] Unable to register cuBLAS factory: Attempting to register factory for plugin cuBLAS when one has already been registered
2024-03-21 07:00:44.470713: I tensorflow/core/platform/cpu_feature_guard.cc:182] This TensorFlow binary is optimized to use available CPU instructions in performance-critical operations.
To enable the following instructions: AVX2 AVX_VNNI FMA, in other operations, rebuild TensorFlow with the appropriate compiler flags.
2024-03-21 07:00:44.800301: W tensorflow/compiler/tf2tensorrt/utils/py_utils.cc:38] TF-TRT Warning: Could not find TensorRT
2024-03-21 07:00:45.358000: I external/local_xla/xla/stream_executor/cuda/cuda_executor.cc:887] could not open file to read NUMA node: /sys/bus/pci/devices/0000:01:00.0/numa_node
Your kernel may have been built without NUMA support.
2024-03-21 07:00:45.371909: I external/local_xla/xla/stream_executor/cuda/cuda_executor.cc:887] could not open file to read NUMA node: /sys/bus/pci/devices/0000:01:00.0/numa_node
Your kernel may have been built without NUMA support.
2024-03-21 07:00:45.371962: I external/local_xla/xla/stream_executor/cuda/cuda_executor.cc:887] could not open file to read NUMA node: /sys/bus/pci/devices/0000:01:00.0/numa_node
Your kernel may have been built without NUMA support.
2024-03-21 07:00:45.375284: I external/local_xla/xla/stream_executor/cuda/cuda_executor.cc:887] could not open file to read NUMA node: /sys/bus/pci/devices/0000:01:00.0/numa_node
Your kernel may have been built without NUMA support.
2024-03-21 07:00:45.375335: I external/local_xla/xla/stream_executor/cuda/cuda_executor.cc:887] could not open file to read NUMA node: /sys/bus/pci/devices/0000:01:00.0/numa_node
Your kernel may have been built without NUMA support.
2024-03-21 07:00:45.375362: I external/local_xla/xla/stream_executor/cuda/cuda_executor.cc:887] could not open file to read NUMA node: /sys/bus/pci/devices/0000:01:00.0/numa_node
Your kernel may have been built without NUMA support.
2024-03-21 07:00:46.059354: I external/local_xla/xla/stream_executor/cuda/cuda_executor.cc:887] could not open file to read NUMA node: /sys/bus/pci/devices/0000:01:00.0/numa_node
Your kernel may have been built without NUMA support.
2024-03-21 07:00:46.059422: I external/local_xla/xla/stream_executor/cuda/cuda_executor.cc:887] could not open file to read NUMA node: /sys/bus/pci/devices/0000:01:00.0/numa_node
Your kernel may have been built without NUMA support.
2024-03-21 07:00:46.059439: I tensorflow/core/common_runtime/gpu/gpu_device.cc:2022] Could not identify NUMA node of platform GPU id 0, defaulting to 0.  Your kernel may not have been built with NUMA support.
2024-03-21 07:00:46.059469: I external/local_xla/xla/stream_executor/cuda/cuda_executor.cc:887] could not open file to read NUMA node: /sys/bus/pci/devices/0000:01:00.0/numa_node
Your kernel may have been built without NUMA support.
2024-03-21 07:00:46.059491: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1929] Created device /job:localhost/replica:0/task:0/device:GPU:0 with 21596 MB memory:  -> device: 0, name: NVIDIA GeForce RTX 3090, pci bus id: 0000:01:00.0, compute capability: 8.6
2024-03-21 07:00:46.790528: I external/local_xla/xla/stream_executor/cuda/cuda_executor.cc:887] could not open file to read NUMA node: /sys/bus/pci/devices/0000:01:00.0/numa_node
Your kernel may have been built without NUMA support.
2024-03-21 07:00:46.790569: I tensorflow/core/grappler/devices.cc:66] Number of eligible GPUs (core count >= 8, compute capability >= 0.0): 1
2024-03-21 07:00:46.790925: I tensorflow/core/grappler/clusters/single_machine.cc:361] Starting new session
2024-03-21 07:00:46.791286: I external/local_xla/xla/stream_executor/cuda/cuda_executor.cc:887] could not open file to read NUMA node: /sys/bus/pci/devices/0000:01:00.0/numa_node
Your kernel may have been built without NUMA support.
2024-03-21 07:00:46.791333: I external/local_xla/xla/stream_executor/cuda/cuda_executor.cc:887] could not open file to read NUMA node: /sys/bus/pci/devices/0000:01:00.0/numa_node
Your kernel may have been built without NUMA support.
2024-03-21 07:00:46.791358: I external/local_xla/xla/stream_executor/cuda/cuda_executor.cc:887] could not open file to read NUMA node: /sys/bus/pci/devices/0000:01:00.0/numa_node
Your kernel may have been built without NUMA support.
2024-03-21 07:00:46.791513: I external/local_xla/xla/stream_executor/cuda/cuda_executor.cc:887] could not open file to read NUMA node: /sys/bus/pci/devices/0000:01:00.0/numa_node
Your kernel may have been built without NUMA support.
2024-03-21 07:00:46.791544: I tensorflow/core/common_runtime/gpu/gpu_device.cc:2022] Could not identify NUMA node of platform GPU id 0, defaulting to 0.  Your kernel may not have been built with NUMA support.
2024-03-21 07:00:46.791562: I external/local_xla/xla/stream_executor/cuda/cuda_executor.cc:887] could not open file to read NUMA node: /sys/bus/pci/devices/0000:01:00.0/numa_node
Your kernel may have been built without NUMA support.
2024-03-21 07:00:46.791572: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1929] Created device /job:localhost/replica:0/task:0/device:GPU:0 with 21596 MB memory:  -> device: 0, name: NVIDIA GeForce RTX 3090, pci bus id: 0000:01:00.0, compute capability: 8.6
2024-03-21 07:00:46.815331: I external/local_xla/xla/stream_executor/cuda/cuda_executor.cc:887] could not open file to read NUMA node: /sys/bus/pci/devices/0000:01:00.0/numa_node
Your kernel may have been built without NUMA support.
2024-03-21 07:00:46.815379: I external/local_xla/xla/stream_executor/cuda/cuda_executor.cc:887] could not open file to read NUMA node: /sys/bus/pci/devices/0000:01:00.0/numa_node
Your kernel may have been built without NUMA support.
2024-03-21 07:00:46.815403: I external/local_xla/xla/stream_executor/cuda/cuda_executor.cc:887] could not open file to read NUMA node: /sys/bus/pci/devices/0000:01:00.0/numa_node
Your kernel may have been built without NUMA support.
2024-03-21 07:00:46.815573: I external/local_xla/xla/stream_executor/cuda/cuda_executor.cc:887] could not open file to read NUMA node: /sys/bus/pci/devices/0000:01:00.0/numa_node
Your kernel may have been built without NUMA support.
2024-03-21 07:00:46.815745: I tensorflow/core/common_runtime/gpu/gpu_device.cc:2022] Could not identify NUMA node of platform GPU id 0, defaulting to 0.  Your kernel may not have been built with NUMA support.
2024-03-21 07:00:46.815827: I external/local_xla/xla/stream_executor/cuda/cuda_executor.cc:887] could not open file to read NUMA node: /sys/bus/pci/devices/0000:01:00.0/numa_node
Your kernel may have been built without NUMA support.
2024-03-21 07:00:46.815849: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1929] Created device /job:localhost/replica:0/task:0/device:GPU:0 with 21596 MB memory:  -> device: 0, name: NVIDIA GeForce RTX 3090, pci bus id: 0000:01:00.0, compute capability: 8.6
2024-03-21 07:00:46.818966: I external/local_xla/xla/stream_executor/cuda/cuda_executor.cc:887] could not open file to read NUMA node: /sys/bus/pci/devices/0000:01:00.0/numa_node
Your kernel may have been built without NUMA support.
2024-03-21 07:00:46.818999: I tensorflow/core/grappler/devices.cc:66] Number of eligible GPUs (core count >= 8, compute capability >= 0.0): 1
2024-03-21 07:00:46.819064: I tensorflow/core/grappler/clusters/single_machine.cc:361] Starting new session
2024-03-21 07:00:46.819249: I external/local_xla/xla/stream_executor/cuda/cuda_executor.cc:887] could not open file to read NUMA node: /sys/bus/pci/devices/0000:01:00.0/numa_node
Your kernel may have been built without NUMA support.
2024-03-21 07:00:46.819273: I external/local_xla/xla/stream_executor/cuda/cuda_executor.cc:887] could not open file to read NUMA node: /sys/bus/pci/devices/0000:01:00.0/numa_node
Your kernel may have been built without NUMA support.
2024-03-21 07:00:46.819293: I external/local_xla/xla/stream_executor/cuda/cuda_executor.cc:887] could not open file to read NUMA node: /sys/bus/pci/devices/0000:01:00.0/numa_node
Your kernel may have been built without NUMA support.
2024-03-21 07:00:46.819394: I external/local_xla/xla/stream_executor/cuda/cuda_executor.cc:887] could not open file to read NUMA node: /sys/bus/pci/devices/0000:01:00.0/numa_node
Your kernel may have been built without NUMA support.
2024-03-21 07:00:46.819409: I tensorflow/core/common_runtime/gpu/gpu_device.cc:2022] Could not identify NUMA node of platform GPU id 0, defaulting to 0.  Your kernel may not have been built with NUMA support.
2024-03-21 07:00:46.819437: I external/local_xla/xla/stream_executor/cuda/cuda_executor.cc:887] could not open file to read NUMA node: /sys/bus/pci/devices/0000:01:00.0/numa_node
Your kernel may have been built without NUMA support.
2024-03-21 07:00:46.819454: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1929] Created device /job:localhost/replica:0/task:0/device:GPU:0 with 21596 MB memory:  -> device: 0, name: NVIDIA GeForce RTX 3090, pci bus id: 0000:01:00.0, compute capability: 8.6
Epoch 1/2
2024-03-21 07:01:05.241732: I external/local_xla/xla/stream_executor/cuda/cuda_dnn.cc:454] Loaded cuDNN version 8904
2024-03-21 07:01:06.098691: I external/local_xla/xla/service/service.cc:168] XLA service 0x5597c1b82fe0 initialized for platform CUDA (this does not guarantee that XLA will be used). Devices:
2024-03-21 07:01:06.098714: I external/local_xla/xla/service/service.cc:176]   StreamExecutor device (0): NVIDIA GeForce RTX 3090, Compute Capability 8.6
2024-03-21 07:01:06.101540: I tensorflow/compiler/mlir/tensorflow/utils/dump_mlir_util.cc:269] disabling MLIR crash reproducer, set env var `MLIR_CRASH_REPRODUCER_DIRECTORY` to enable.
WARNING: All log messages before absl::InitializeLog() is called are written to STDERR
I0000 00:00:1711000866.141881    2374 device_compiler.h:186] Compiled cluster using XLA!  This line is logged at most once for the lifetime of the process.
534/538 [============================>.] - ETA: 0s - loss: 3.3772 - categorical_accuracy: 0.4657
Epoch 1: val_loss improved from 1000000000.00000 to 2.42523, saving model to /mnt/c/tmp/mnistv1/chk/mnist_0000001_.weights.h5
538/538 [==============================] - 24s 8ms/step - loss: 3.3665 - categorical_accuracy: 0.4622 - val_loss: 2.4252 - val_categorical_accuracy: 0.1082
Epoch 2/2
537/538 [============================>.] - ETA: 0s - loss: 1.8717 - categorical_accuracy: 0.5926
Epoch 2: val_loss did not improve from 2.42523
538/538 [==============================] - 5s 9ms/step - loss: 1.8683 - categorical_accuracy: 0.5934 - val_loss: 10.5518 - val_categorical_accuracy: 0.1271

from tensorflow-onnx.

anliec avatar anliec commented on June 2, 2024

After installing tf 2.15.1 all the errors went away (still using tf2onnx 1.16.1).
Not sure who his to blame here, but there is at least a compatibility issue with tf 2.16

from tensorflow-onnx.

LaurentBerger avatar LaurentBerger commented on June 2, 2024

I posted another issue about tflite : problem with tf 2.16 but not with 2.15
Tensorflow or onnx?

from tensorflow-onnx.

fatcat-z avatar fatcat-z commented on June 2, 2024

I posted another issue about tflite : problem with tf 2.16 but not with 2.15 Tensorflow or onnx?

By the issue you described in TensorFlow repo, I think we should make sure the tflite model is correct and then check if it could be converted to ONNX successfully.

from tensorflow-onnx.

LaurentBerger avatar LaurentBerger commented on June 2, 2024

By the issue you described in TensorFlow repo, I think we should make sure the tflite model is correct and then check if it could be converted to ONNX successfully.

I think that there is a bug in TF2.16.1 with consequence on tfonnx and saving tflite model.
For fun model is lenet5 and may be I can call tf2.16.1 oedipe version

from tensorflow-onnx.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.