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

ModifyGraphWithDelegate(delegate) running very slow (ubuntu with USB accelerator) #47383

Closed
JohannSchumann opened this issue Feb 24, 2021 · 7 comments
Assignees
Labels
comp:lite TF Lite related issues type:performance Performance Issue

Comments

@JohannSchumann
Copy link

Hi,
I wrote a minimal C++ code loading the mobilenet_v2_1.0_224_inat_bird_quant_edgetpu.tflite
and doing some inferencing.
When running on a ubuntu-16.04 notebook (i7, SSD, 12G) with USB accelerator,
interpreter_->ModifyGraphWithDelegate
runs substantially (50x) slower than the same(see below) code on the dev-board.

Dev-board:
Code line: interpreter_->ModifyGraphWithDelegate({delegate, edgetpu_free_delegate});
libedgetpu version: libedgetpu1-std:arm64 14.1
run time: 0.07sec (incl. loading network etc)

Ubuntu 16.04,
Code line: interpreter_->ModifyGraphWithDelegate(delegate);
[ the version above with the 2 delegates can't be compiled]
libedgetpu: libedgetpu1-max/coral-edgetpu-stable,now 15.0 amd64 [installed]
TENSORFLOW: tensorflow_src cloned today and built tflite library
runtime: 3.2sec (!)

After that, the inference is running about only half as fast as on the devboard.
(slower USB speed??? or problem with the delegate?)

Code snippet:
std::unique_ptrtflite::FlatBufferModel model;
model = tflite::FlatBufferModel::BuildFromFile(model_path.c_str());

tflite::ops::builtin::BuiltinOpResolver resolver;
tflite::InterpreterBuilder(*model, resolver)(&interpreter_);

size_t num_devices;
std::unique_ptr<edgetpu_device, decltype(&edgetpu_free_devices)> devices(
edgetpu_list_devices(&num_devices), &edgetpu_free_devices);
TFLITE_MINIMAL_CHECK(num_devices);
const auto& device = devices.get()[0];
auto* delegate = edgetpu_create_delegate(device.type, device.path, nullptr, 0);
ON DEVBOARD: interpreter_->ModifyGraphWithDelegate({delegate, edgetpu_free_delegate});
ON UBUNTU/USB: interpreter_->ModifyGraphWithDelegate(delegate);

Thank you!
-johann

@JohannSchumann JohannSchumann added the type:performance Performance Issue label Feb 24, 2021
@Saduf2019 Saduf2019 added comp:runtime c++ runtime, performance issues (cpu) comp:lite TF Lite related issues labels Feb 25, 2021
@Saduf2019
Copy link
Contributor

@JohannSchumann
We see that the issue template has not been filled, could you please do so as it helps us analyse the issue [tf version, steps followed before you ran into this error or stand alone code to reproduce the issue faced]

@Saduf2019 Saduf2019 added the stat:awaiting response Status - Awaiting response from author label Feb 25, 2021
@JohannSchumann
Copy link
Author

JohannSchumann commented Feb 25, 2021 via email

@tensorflowbutler tensorflowbutler removed the stat:awaiting response Status - Awaiting response from author label Feb 27, 2021
@Saduf2019 Saduf2019 assigned ymodak and unassigned Saduf2019 Mar 1, 2021
@terryheo
Copy link
Member

terryheo commented Mar 3, 2021

@JohannSchumann did you use USB 3.0 port to connect the accelerator?

@JohannSchumann
Copy link
Author

JohannSchumann commented Mar 7, 2021 via email

@terryheo
Copy link
Member

terryheo commented Mar 8, 2021

Is the source at #47383 (comment) what you're using?
Could you share where you referred?

What I found was the following page which uses external context. It might worth to try.
https://coral.ai/docs/edgetpu/tflite-cpp/#set-up-the-tf-lite-interpreter-with-libedgetpu

Also I wonder if you see the same symptom with Python example.

@terryheo terryheo self-assigned this Mar 9, 2021
@ymodak ymodak added stat:awaiting response Status - Awaiting response from author and removed comp:runtime c++ runtime, performance issues (cpu) labels Mar 10, 2021
@ymodak ymodak removed their assignment Mar 10, 2021
@JohannSchumann
Copy link
Author

JohannSchumann commented Mar 12, 2021 via email

@tensorflowbutler tensorflowbutler removed the stat:awaiting response Status - Awaiting response from author label Mar 14, 2021
@terryheo
Copy link
Member

You'd better file a bug under Coral page. This is not something TF team can answer.

https://github.com/google-coral/edgetpu/issues

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
comp:lite TF Lite related issues type:performance Performance Issue
Projects
None yet
Development

No branches or pull requests

5 participants