tensorflow: Dev-board Interpretere Runtime Error

I am working on the Coral dev board. I’m trying to deploy a segmentation model on it. When I’m running my deep lab segmentation model it is giving me the following error-

Traceback (most recent call last):
  File "infer.py", line 17, in <module>
    interpreter.allocate_tensors()
  File "/home/mendel/.local/lib/python3.5/site-packages/tflite_runtime/interpreter.py", line 244, in allocate_tensors
    return self._interpreter.AllocateTensors()
  File "/home/mendel/.local/lib/python3.5/site-packages/tflite_runtime/interpreter_wrapper.py", line 114, in AllocateTensors
    return _interpreter_wrapper.InterpreterWrapper_AllocateTensors(self)
RuntimeError: Internal: :71 tf_lite_type != kTfLiteUInt8 (9 != 3)Node number 79 (EdgeTpuDelegateForCustomOp) failed to prepare.

The model and script are working fine if I don’t make it TPU compatible using edgetpu_compiler.

Code to reproduce the issue

from tqdm import tqdm
import numpy as np
from tflite_runtime.interpreter import Interpreter
from tflite_runtime.interpreter import load_delegate

test_data = np.random.rand(480,480,3)
img = np.array([test_data], dtype=np.float32)

interpreter = Interpreter(
      model_path="deep_lab_quant_edgetpu.tflite",
      experimental_delegates=[load_delegate('libedgetpu.so.1.0')])

interpreter.allocate_tensors()

input_details = interpreter.get_input_details()
output_details = interpreter.get_output_details()
interpreter.set_tensor(input_details[0]['index'], img)
interpreter.invoke()
output_data = interpreter.get_tensor(output_details[0]['index'])

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 18

Most upvoted comments

I get the same error for my custom image processing model. I don’t truly know the source of the error, but have found that when reducing the size of the model (number of channels in each layer) and/or the input tensor (height and width dimensions), the error goes away.

However, the output of the edgetpu compiler suggests that even my “full-size” model easily fits on the TPU:

Input model: model.tflite
Input size: 925.08KiB
Output model: model_edgetpu.tflite
Output size: 1.04MiB
On-chip memory available for caching model parameters: 5.78MiB
On-chip memory used for caching model parameters: 1019.75KiB
Off-chip memory used for streaming uncached model parameters: 0.00B
Number of Edge TPU subgraphs: 1
Total number of operations: 54
Operation log: model_edgetpu.log

Here are my system specs:

Linux kernel version:
$ uname -r
4.4.0-96-generic

Linux release:
$ lsb_release -a
Distributor ID:	Ubuntu
Description:	Ubuntu 16.04.6 LTS
Release:	16.04
Codename:	xenial

Tensorflow python module version
2.0.0-rc0

Edge TPU python module version:
2.12.1

Edge TPU compiler version:
Edge TPU Compiler version 2.0.267685300

Edge TPU runtime version:
BuildLabel(COMPILER=5.4.0 20160609,DATE=redacted,TIME=redacted,CL_NUMBER=267685300), RuntimeVersion(12)

Paths of available Edge TPU devices, if any:
('/sys/bus/usb/devices/4-3',)

@Namburger Thanks for the suggestion. Our code worked after downgrading to tf 1.15 and retraining the Keras model.

@mattroos thanks for your suggestion. This did not solve my error though! Below is the output log of edgetpu compilation of .tflite model. I’m using deeplab for segmentation. let me know if you are able to capture any error here. Also, can you suggest me any other model which can be run on coral dev board? Thanks.

Edge TPU Compiler version 2.0.267685300
Input: deep_lab_quant.tflite
Output: deep_lab_quant_edgetpu.tflite

Operator                       Count      Status

QUANTIZE                       1          More than one subgraph is not supported
QUANTIZE                       1          Operation is otherwise supported, but not mapped due to some unspecified limitation
MUL                            10         More than one subgraph is not supported
RESHAPE                        1          More than one subgraph is not supported
RESIZE_BILINEAR                2          Image-interpolation layer won't run precisely enough on Edge TPU
ADD                            3          Mapped to Edge TPU
ADD                            7          More than one subgraph is not supported
CONCATENATION                  1          More than one subgraph is not supported
CONV_2D                        15         Mapped to Edge TPU
CONV_2D                        23         More than one subgraph is not supported
DEPTHWISE_CONV_2D              7          Mapped to Edge TPU
DEPTHWISE_CONV_2D              10         Tensor has unsupported rank (up to 3 innermost dimensions mapped)
BATCH_TO_SPACE_ND              10         Operation not supported
DEQUANTIZE                     1          Operation is working on an unsupported data type
SPACE_TO_BATCH_ND              10         Tensor has unsupported rank (up to 3 innermost dimensions mapped)
MEAN                           1          More than one subgraph is not supported