Cannot mix OTBTF application and Tensorflow in Python
This piece of script raises an error on the last line
import tensorflow as tf
import otbApplication
# Create a dummy Tensorflow model and save it
x1 = tf.keras.Input(shape=[None, None, 4]) # [h, w, N]
x2 = tf.keras.Input(shape=[None, None, 4]) # [h, w, N]
y = tf.math.multiply(x1, x2)
model = tf.keras.Model(inputs=[x1, x2], outputs=y, name="multiply")
model.save("my_model_multiply")
# Create an OTB application
serve = otbApplication.Registry.CreateApplication('TensorflowModelServe')
Was run in 4 differents environments and raised different errors.
On mdl4eo/otbtf2.4:cpu
and mdl4eo/otbtf2.4:gpu
:
[libprotobuf ERROR external/com_google_protobuf/src/google/protobuf/descriptor_database.cc:118] File already exists in database: tensorflow/core/profiler/profiler_service_monitor_result.proto
[libprotobuf FATAL external/com_google_protobuf/src/google/protobuf/descriptor.cc:1379] CHECK failed: GeneratedDatabase()->Add(encoded_file_descriptor, size):
Traceback (most recent call last):
File "pyotb.py", line 12, in <module>
serve = otbApplication.Registry.CreateApplication('TensorflowModelServe')
on mdl4eo/otbtf2.5:gpu
and mdl4eo/otbtf2.5:cpu
:
2021-10-28 13:31:51.933796: E tensorflow/core/lib/monitoring/collection_registry.cc:77] Cannot register 2 metrics with the same name: /tensorflow/core/op_expansion/node_counter
2021-10-28 13:31:51.933889: E tensorflow/core/lib/monitoring/collection_registry.cc:77] Cannot register 2 metrics with the same name: /tensorflow/core/op_expansion/graph_counter
2021-10-28 13:31:51.933922: E tensorflow/core/lib/monitoring/collection_registry.cc:77] Cannot register 2 metrics with the same name: /tensorflow/core/op_expansion/op_counter
2021-10-28 13:31:51.933988: F tensorflow/core/framework/device_factory.cc:90] Duplicate registration of device factory for type XLA_CPU with the same priority 50
Aborted (core dumped)