Skip to content
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

Command 'edgetpu_compiler --version' returned non-zero #6215

Closed
1 of 2 tasks
dariogonle opened this issue Jan 5, 2022 · 5 comments · Fixed by #6223
Closed
1 of 2 tasks

Command 'edgetpu_compiler --version' returned non-zero #6215

dariogonle opened this issue Jan 5, 2022 · 5 comments · Fixed by #6223
Labels
bug Something isn't working

Comments

@dariogonle
Copy link

dariogonle commented Jan 5, 2022

Search before asking

  • I have searched the YOLOv5 issues and found no similar bug report.

YOLOv5 Component

Export

Bug

I was trying to export yolov5n.pt to edgetpu running the following command:

python3 export.py --weights yolov5n.pt --img-size 640 --include edgetpu

It exports correctly the model to TF, but at the time of edge tpu I get the following message:

image

Does anybody exported it correctly?

Thank you in advance.

Environment

Ubuntu 20.04
Python 3.8.10

Minimal Reproducible Example

No response

Additional

No response

Are you willing to submit a PR?

  • Yes I'd like to help by submitting a PR!
@dariogonle dariogonle added the bug Something isn't working label Jan 5, 2022
@glenn-jocher
Copy link
Member

@dariogonle Edge TPU export requires edgetpu_compiler installed on your system. See https://coral.ai/docs/edgetpu/compiler/

@dariogonle
Copy link
Author

Thank you so much @glenn-jocher.

@glenn-jocher
Copy link
Member

@dariogonle good news 😃! Your original issue may now be fixed ✅ in PR #6223. This PR enables automatic installation of Edge TPU compiler if required during export of Edge TPU models:

python export.py --weights yolov5s.pt --include edgetpu

To receive this update:

  • Gitgit pull from within your yolov5/ directory or git clone https://github.com/ultralytics/yolov5 again
  • PyTorch Hub – Force-reload model = torch.hub.load('ultralytics/yolov5', 'yolov5s', force_reload=True)
  • Notebooks – View updated notebooks Open In Colab Open In Kaggle
  • Dockersudo docker pull ultralytics/yolov5:latest to update your image Docker Pulls

Thank you for spotting this issue and informing us of the problem. Please let us know if this update resolves the issue for you, and feel free to inform us of any other issues you discover or feature requests that come to mind. Happy trainings with YOLOv5 🚀!

@dariogonle
Copy link
Author

dariogonle commented Jan 6, 2022

Hi @glenn-jocher,
I've git pulled the repo and I've run:

python3 export.py --weights yolov5n.pt --include edgetpu

Apparently, it works fine but the model yolov5n-int8_edgetpu.tflite is not generated. The log says it is, but it's not. What's more it says that it is 0.0MB.

The only thing I see that was generated is yolov5n-int8.tflite but I suppose that this is a previous model required to generate the edgtpu model.

image

Another anomaly I've found is that if I run

python3 export.py --weights yolov5n.pt --include edgetpu --img-size 704

The export script gives the following error:
image

If I use img-size of 416 it works fine (I mean as with 640), but with 704 it seems to be to big. Is there any explication?

EDIT:

I run on a terminal

edgetpu_compiler -s yolov5n-int8.tflite

And I got the yolov5n-int8_edgetpu.tflite. There might be a problem here, but I don't see it

yolov5/export.py

Lines 308 to 332 in f80c463

def export_edgetpu(keras_model, im, file, prefix=colorstr('Edge TPU:')):
# YOLOv5 Edge TPU export https://coral.ai/docs/edgetpu/models-intro/
try:
cmd = 'edgetpu_compiler --version'
help_url = 'https://coral.ai/docs/edgetpu/compiler/'
assert platform.system() == 'Linux', f'export only supported on Linux. See {help_url}'
if subprocess.run(cmd, shell=True).returncode != 0:
LOGGER.info(f'\n{prefix} export requires Edge TPU compiler. Attempting install from {help_url}')
for c in ['curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -',
'echo "deb https://packages.cloud.google.com/apt coral-edgetpu-stable main" | sudo tee /etc/apt/sources.list.d/coral-edgetpu.list',
'sudo apt-get update',
'sudo apt-get install edgetpu-compiler']:
subprocess.run(c, shell=True, check=True)
ver = subprocess.run(cmd, shell=True, capture_output=True, check=True).stdout.decode().split()[-1]
LOGGER.info(f'\n{prefix} starting export with Edge TPU compiler {ver}...')
f = str(file).replace('.pt', '-int8_edgetpu.tflite') # Edge TPU model
f_tfl = str(file).replace('.pt', '-int8.tflite') # TFLite model
cmd = f"edgetpu_compiler -s {f_tfl}"
subprocess.run(cmd, shell=True, check=True)
LOGGER.info(f'{prefix} export success, saved as {f} ({file_size(f):.1f} MB)')
except Exception as e:
LOGGER.info(f'\n{prefix} export failure: {e}')

@glenn-jocher
Copy link
Member

glenn-jocher commented Jan 6, 2022

@dariogonle 👋 hi, thanks for letting us know about this possible problem with YOLOv5 🚀.

Your Edge TPU export at --img 704 issue is already explained in the error message in your screenshot "Compilation failed due to large activation tensors in model".

Your Edge TPU export for python3 export.py --weights yolov5n.pt --include edgetpu produces no errors:
Screen Shot 2022-01-06 at 9 36 26 AM

We've created a few short guidelines below to help users provide what we need in order to get started investigating a possible problem.

How to create a Minimal, Reproducible Example

When asking a question, people will be better able to provide help if you provide code that they can easily understand and use to reproduce the problem. This is referred to by community members as creating a minimum reproducible example. Your code that reproduces the problem should be:

  • Minimal – Use as little code as possible to produce the problem
  • Complete – Provide all parts someone else needs to reproduce the problem
  • Reproducible – Test the code you're about to provide to make sure it reproduces the problem

For Ultralytics to provide assistance your code should also be:

  • Current – Verify that your code is up-to-date with GitHub master, and if necessary git pull or git clone a new copy to ensure your problem has not already been solved in master.
  • Unmodified – Your problem must be reproducible using official YOLOv5 code without changes. Ultralytics does not provide support for custom code ⚠️.

If you believe your problem meets all the above criteria, please close this issue and raise a new one using the 🐛 Bug Report template with a minimum reproducible example to help us better understand and diagnose your problem.

Thank you! 😃

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants