google-coral / edgetpu

Coral issue tracker (and legacy Edge TPU API source)
https://coral.ai
Apache License 2.0
423 stars 124 forks source link

Error opening file for writing: edgetpu/best-int8_edgetpu.tflite Internal compiler error. Aborting! #400

Closed thongvhoang closed 3 years ago

thongvhoang commented 3 years ago

I use this code for converting full int8 TFLite model to Edge TPU by following link: https://github.com/zldrobit/yolov5/tree/tf-android-tfl-detect: Code: !edgetpu_compiler -s -a -o edgetpu $yolov5s_int8_path

Bug error generate by this code:

Edge TPU Compiler version 15.0.340273435

Model compiled successfully in 2375 ms.

Input model: /content/drive/MyDrive/yolov5/runs/train/yolov5s_results/weights/best-int8.tflite
Input size: 7.34MiB
Output model: edgetpu/best-int8_edgetpu.tflite
Output size: 7.84MiB
On-chip memory used for caching model parameters: 6.73MiB
On-chip memory remaining for caching model parameters: 6.75MiB
Off-chip memory used for streaming uncached model parameters: 411.38KiB
Number of Edge TPU subgraphs: 12
Total number of operations: 255
Operation log: edgetpu/best-int8_edgetpu.log

Model successfully compiled but not all operations are supported by the Edge TPU. A percentage of the model will instead run on the CPU, which is slower. If possible, consider updating your model to use only operations supported by the Edge TPU. For details, visit g.co/coral/model-reqs.
Number of operations that will run on Edge TPU: 235
Number of operations that will run on CPU: 20

Operator                       Count      Status

RESIZE_NEAREST_NEIGHBOR        2          Operation version not supported
CONCATENATION                  14         Mapped to Edge TPU
RESHAPE                        3          Mapped to Edge TPU
TRANSPOSE                      3          Operation not supported
MUL                            59         Mapped to Edge TPU
STRIDED_SLICE                  4          Only Strided-Slice with unitary strides supported
LOGISTIC                       51         Mapped to Edge TPU
LEAKY_RELU                     8          Operation not supported
PAD                            6          Mapped to Edge TPU
ADD                            15         Mapped to Edge TPU
MAX_POOL_2D                    3          Mapped to Edge TPU
QUANTIZE                       14         Mapped to Edge TPU
QUANTIZE                       3          Operation is otherwise supported, but not mapped due to some unspecified limitation
CONV_2D                        70         Mapped to Edge TPU
Error opening file for writing: edgetpu/best-int8_edgetpu.tflite

Internal compiler error. Aborting! 

In additional, I run the code:edgetpu_compiler -a $yolov5s_int8_path -> Successfully. But deploy mobile when running app on Android Studio, appears the bug error: E/AndroidRuntime: FATAL EXCEPTION: inference Process: org.tensorflow.lite.examples.detection, PID: 21132 java.lang.RuntimeException: java.lang.IllegalStateException: Internal error: Unexpected failure when preparing tensor allocations: Encountered unresolved custom op: edgetpu-custom-op. Node number 0 (edgetpu-custom-op) failed to prepare.

My environment: I use Google Colab (Ubuntu 18.04), Tensorflow 2.4.0 Object Detection Model: YOLOv5s-int8

In conclusion, I want to ask how to fix that error above "Error opening file for writing" and "E/AndroidRuntime: FATAL EXCEPTION: inference" Thank you.

thongvhoang commented 3 years ago

I use this code for converting full int8 TFLite model to Edge TPU by following link: https://github.com/zldrobit/yolov5/tree/tf-android-tfl-detect: Code: !edgetpu_compiler -s -a -o edgetpu $yolov5s_int8_path

Bug error generate by this code:

Edge TPU Compiler version 15.0.340273435

Model compiled successfully in 2375 ms.

Input model: /content/drive/MyDrive/yolov5/runs/train/yolov5s_results/weights/best-int8.tflite
Input size: 7.34MiB
Output model: edgetpu/best-int8_edgetpu.tflite
Output size: 7.84MiB
On-chip memory used for caching model parameters: 6.73MiB
On-chip memory remaining for caching model parameters: 6.75MiB
Off-chip memory used for streaming uncached model parameters: 411.38KiB
Number of Edge TPU subgraphs: 12
Total number of operations: 255
Operation log: edgetpu/best-int8_edgetpu.log

Model successfully compiled but not all operations are supported by the Edge TPU. A percentage of the model will instead run on the CPU, which is slower. If possible, consider updating your model to use only operations supported by the Edge TPU. For details, visit g.co/coral/model-reqs.
Number of operations that will run on Edge TPU: 235
Number of operations that will run on CPU: 20

Operator                       Count      Status

RESIZE_NEAREST_NEIGHBOR        2          Operation version not supported
CONCATENATION                  14         Mapped to Edge TPU
RESHAPE                        3          Mapped to Edge TPU
TRANSPOSE                      3          Operation not supported
MUL                            59         Mapped to Edge TPU
STRIDED_SLICE                  4          Only Strided-Slice with unitary strides supported
LOGISTIC                       51         Mapped to Edge TPU
LEAKY_RELU                     8          Operation not supported
PAD                            6          Mapped to Edge TPU
ADD                            15         Mapped to Edge TPU
MAX_POOL_2D                    3          Mapped to Edge TPU
QUANTIZE                       14         Mapped to Edge TPU
QUANTIZE                       3          Operation is otherwise supported, but not mapped due to some unspecified limitation
CONV_2D                        70         Mapped to Edge TPU
Error opening file for writing: edgetpu/best-int8_edgetpu.tflite

Internal compiler error. Aborting! 

In additional, I run the code:edgetpu_compiler -a $yolov5s_int8_path -> Successfully. But deploy mobile when running app on Android Studio, appears the bug error: E/AndroidRuntime: FATAL EXCEPTION: inference Process: org.tensorflow.lite.examples.detection, PID: 21132 java.lang.RuntimeException: java.lang.IllegalStateException: Internal error: Unexpected failure when preparing tensor allocations: Encountered unresolved custom op: edgetpu-custom-op. Node number 0 (edgetpu-custom-op) failed to prepare.

My environment: I use Google Colab (Ubuntu 18.04), Tensorflow 2.4.0 Object Detection Model: YOLOv5s-int8

In conclusion, I want to ask how to fix that error "Error opening file for writing" Thank you.

I fixed the error "Error opening file for writing": Option 1: Remove "edgetpu" Option 2: Create folder edgetpu

manoj7410 commented 3 years ago

@thongvhoang Can this issue be closed now ?

thongvhoang commented 3 years ago

@thongvhoang Can this issue be closed now ?

Yes, it can.