-
Notifications
You must be signed in to change notification settings - Fork 124
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Compilation failed due to large activation tensors in model. #439
Comments
@xsacha Can you share your CPU .tflite model here ? |
facedetector.zip |
@xsacha Did you try to reduce the Tensor size of (1, 3, 768, 1024) ? |
I haven't attempted it yet. The original model runs at any resolution. Is there a limitation on the TPU? Edit#2: For the second issue I get (on runtime 10 and 11), where none of the OPs map to the TPU: the issue appears to be the conversion from UINT8 (input) to INT8. From reading, this is a Tensorflow 2.X change that isn't supported here. I found a rather complicated workaround here: https://towardsdatascience.com/hacking-google-coral-edge-tpu-motion-blur-and-lanczos-resize-9b60ebfaa552 that allows modifying the types to uint8 so that they can run on the TPU. |
I've had several more attempts at this. Using v1 converter, using much smaller input size, manually allowing only uint8 ops and such and still can't get it working. Q1. Does every op have to be uint8 to run on the TPU? I notice the first thing the TFlite does is quantize to signed int8. I feel there's a lack of documentation around this issue. I also haven't been able to find any tutorial online that can successfully convert any of my models even though all the OPs are supported. |
Yes. Every operations has to be int8 quantized in order to run on the TPU. Please see the model requirements at https://coral.ai/docs/edgetpu/models-intro/#model-requirements
TF2 models are compatible with the edgeTPU.
Please see the documentation https://coral.ai/docs/edgetpu/models-intro/#compatibility-overview for the model compatibility information.
You can find many tutorials around this issue at https://github.com/google-coral/tutorials. We are always eager to improve our documentation and make it more smooth for the TPU users. |
@manoj7410
Is this out of date? I am using the post-training quantization in TF 2.5 right now and wondering if that is an issue. I can set uint8 as input and output but the actual ops have to be int8. Due to this error (large activation tensors in model), I cannot use runtimes that support Quantize (13+), so I changed it to use int8 input and output. From what you have said, this should work but it still provides the same issue. Also, I couldn't find on any of those pages, including model compatibility link above, if a channels-first approach would fail or not. That is the following shape input: 1x3x480x640 Edit: I also uploaded several models to the coral tutorials to quantize and convert to edge tpu and they all failed with this same issue. |
Please see the section : "Can I use TensorFlow 2.0 to create my model?" at https://coral.ai/docs/edgetpu/faq/. |
@xsacha Channel first approach might fail, as tflite and edgetpu_compiler doesn't fully support all the ops. |
I used a channels-last version instead (same model would fail on all ops as channels-first) and got the following:
It looks like then that it isn't possible for me to convert a model from PyTorch/ONNX that can then work on the Edge TPU as they only have facility for channels-first ops (channels-last memory layout only). |
@xsacha Can you take a look at this comment once #419 (comment) |
Thanks. That looks promising. From what I can see, it goes via openvino to perform the conversion and that extra step might introduce other limitations but it opens up a better possibility than retraining all the models! |
As an update, I managed to convert one of my models that was getting this error using the method you linked to. |
Is there any explanation of what this error means? Is there a workaround?
The model is only 800KB so I'm unsure how any part could be too large. It's an INT8 TFLITE model that was created using this script with input size set to (1, 3, 768, 1024) [NCHW].
Edit: I found targeting an older runtime version allows it to successfully compile. Default was 14. 12 and above fail but 11 works.
Although successful, it then fails to map any OPs to the TPU.
The text was updated successfully, but these errors were encountered: