profile
viewpoint

Ask questionstflite crash with segmentfault when I use set_tensor to set input tensor.

System information

  • Have I written custom code (as opposed to using a stock example script provided in TensorFlow): Yes

  • OS Platform and Distribution (e.g., Linux Ubuntu 16.04): Ubuntu16.04 windows and Raspbian 10

  • Mobile device (e.g. iPhone 8, Pixel 2, Samsung Galaxy) if the issue happens on mobile device: I test it both on x64 and armv7l (Raspberry Pi4 which is running 32bit OS)

  • TensorFlow installed from (source or binary): from binary

  • TensorFlow version (use command below): I test with 2.0 1.12

  • Python version: 3.7

Describe the current behavior As I use tf1.12 produce a saved_model.pb, I use tf2.0 to convert it to tflite file. But when I try to inference with tflite. it alway crash with segment fault when I try to set_tensor. I tried it on windows and linux and raspberry pi, all doesn't work.

I have test the saved_model.pb as it work well, so I think the it's not the model's problem.

Code to reproduce the issue I use the following code to convert the model to tflite: `import tensorflow as tf

converter = tf.lite.TFLiteConverter.from_saved_model('./')

tflite_model = converter.convert()

open('model_network.tflite', 'wb').write(tflite_model)`

and following code to inference: ` interpreter = tf.lite.Interpreter(model_path=model_path)

input_details = interpreter.get_input_details()

output_details = interpreter.get_output_details()

input_shape = input_details[0]['shape']

input_data = np.array(np.random.random_sample(input_shape), dtype=np.float32)

interpreter.set_tensor(input_details[0]['index'], input_data)

interpreter.invoke()

result = interpreter.get_tensor(output_details[0]['index']) ` it crash when interpreter.set_tensor I attach my model files here. https://drive.google.com/file/d/1NflTBZ2iB4hptDozODdaSke4o7pzPBNW/view?usp=sharing The original code is to long, if needed I can upload it later.

tensorflow/tensorflow

Answer questions aselle

I also submitted a fix (above) 5521416 so this warns you that allocate needs to be called first.

useful!

Related questions

Error occurred when finalizing GeneratorDataset iterator
ModuleNotFoundError: No module named 'tensorflow.contrib'
ModuleNotFoundError: No module named 'tensorflow.contrib' hot 4
When importing TensorFlow, error loading Hadoop hot 4
The flag 'log_dir' is defined twice. hot 3
[TF 2.0] Dataset has no attribute 'make_one_shot_iterator' hot 3
Lossy conversion from float32 to uint8. Range [0, 1]. Convert image to uint8 prior to saving to suppress this warning. hot 3
TF2.0 AutoGraph issue hot 3
Error loading tensorflow hot 3
AttributeError: module 'tensorflow' has no attribute 'set_random_seed' hot 3
No tf.lite.experimental.nn.bidirectional_dynamic_rnn ops is finded hot 3
Incorrect Error TypeError: padded_batch() missing 1 required positional argument: 'padded_shapes' hot 3
tensorflow2.0 detected 'xla_gpu' , but 'gpu' expected hot 2
Using tensorflow gpu 2.1 with Cuda 10.2 hot 2
Restoring Keras model fails inside a distribution strategy scope hot 2
Github User Rank List