mattn / go-tflite

Go binding for TensorFlow Lite
MIT License
304 stars 44 forks source link

Raspberry Pi 4 + edgetpu "Internal: Unsupported data type in custom op handler: 0" #30

Closed KyungWonPark closed 4 years ago

KyungWonPark commented 4 years ago

Hello

I tried to run example with edgetpu but it gives me

EdgeTPU Version: BuildLabel(COMPILER=6.3.0 20170516,DATE=redacted,TIME=redacted,CL_NUMBER=291256449), RuntimeVersion(13)
Internal: Unsupported data type in custom op handler: 0
Node number -1095957936 (8ɶ<­¾üÍ϶D) @2.

2020/06/15 23:44:53 allocate failed

What would be the cause?

KyungWonPark commented 4 years ago

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

Seems like this issue

I confirm that version 13.0 or the runtime (libedgetpu1) fails on all models that previously worked on runtime version 12.1. This is regardless on the TF version the initial tflite models were generated and the edgetpu-compiler used for the conversion.

As a note: the older runtimes are no longer available so inference is currently broken unless someone does not update to the new runtimes. This is hard, as the new ones are currently pushed through the apt upgrade process.
KyungWonPark commented 4 years ago

I tried "go-tflite/_example/label_image_edgetpu" example with new ssd_v2 network from https://coral.ai/models/

But still it returns

EdgeTPU Version: BuildLabel(COMPILER=6.3.0 20170516,DATE=redacted,TIME=redacted,CL_NUMBER=291256449), RuntimeVersion(13)
Internal: Unsupported data type in custom op handler: 18170432
Node number -1098788272 ¶<ҁ¾üȶD) çßðÀ.

2020/06/15 23:55:34 allocate failed

go-tflite edgetpu still breaks with latest edgetpu model

KyungWonPark commented 4 years ago

I tested edgetpu python examples and they work fine Seems like problem on this side

go-tflite successfully gets edgetpu device list and create interpreter But it fails to allocate tensors

Error reporter callback function prints weird message

Internal: Unsupported data type in custom op handler: 18170432
Node number -1098788272 ¶<ҁ¾üȶD) çßðÀ.

Maybe this could give us some hint?

mattn commented 4 years ago

Did you build libtensorflow-lite.a with commit d855adfc5a0195788bf5f92c3c7352e638aa1109 ?

mattn commented 4 years ago

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

KyungWonPark commented 4 years ago

Hello

Could you elaborate some more of what I should do?

I compiled "libtensorflowlite_c.so" in tensorflow/tensorflow/lite/c directory, fetched from tensorflow github with Makefile.tflite you wrote

mattn commented 4 years ago

Checkout specified commit d855adfc5a0195788bf5f92c3c7352e638aa1109

$ git checkout d855adfc5a0195788bf5f92c3c7352e638aa1109

And build libtensorflow-lite.a and libtensorflowlite_c.so again.

KyungWonPark commented 4 years ago

Thank you very much

I'll try it now

Do you know why this happens?

Is this some compatibility issue between edgetpu and tflite?

mattn commented 4 years ago

edgetpu does not support latest tensorflow.

KyungWonPark commented 4 years ago

Now it's working fine on Raspberry pi 4 + edgetpu

Closing issue

anoop54 commented 4 years ago

Hi guys, would love some help here. I'm just a little confused here, so I cloned https://github.com/tensorflow/tensorflow and then build just for the TF_LITE libraries and like Kyung I had the same error. So now you are saying git clone https://github.com/tensorflow/tensorflow and then git checkout d855adfc5a0195788bf5f92c3c7352e638aa1109 ? I get the error fatal: not a git repository (or any of the parent directories): .git

KyungWonPark commented 4 years ago

Hi guys, would love some help here. I'm just a little confused here, so I cloned https://github.com/tensorflow/tensorflow and then build just for the TF_LITE libraries and like Kyung I had the same error. So now you are saying git clone https://github.com/tensorflow/tensorflow and then git checkout d855adfc5a0195788bf5f92c3c7352e638aa1109 ? I get the error fatal: not a git repository (or any of the parent directories): .git

Checkout at the "tensorflow" directory not at the "tensorflow/tensorflow"

anoop54 commented 4 years ago

Wow. Nice catch, thanks Kyung.

KyungWonPark commented 4 years ago

Wow. Nice catch, thanks Kyung.

You're welcome.

By the way my first name is KyungWon... Last name is Park...... it's korean style

What are you building with RPI + coral accelerator?

anoop54 commented 4 years ago

Nice to meet you KyungWon, my name is Anoop. I'm actually one of the developers on this project https://www.kickstarter.com/projects/axibomedia/axibo and we are using golang + coral tpu on our custom computer.

KyungWonPark commented 4 years ago

Nice to meet you KyungWon, my name is Anoop. I'm actually one of the developers on this project https://www.kickstarter.com/projects/axibomedia/axibo and we are using golang + coral tpu on our custom computer.

It's so cool! I'm playing with raspberry pi 12MP camera recently released

Do you know OpenCV also has Go wrapper? It's GoCV and thats awesome too

anoop54 commented 4 years ago

Yes, I've been playing around with it. We are integrating things with zeromq for messaging between nodes. Library for ZeroMq is also working really well with go. This is my fist goLang project.

anoop54 commented 4 years ago

Also quick question, what FPS are you getting on the SSD model?

KyungWonPark commented 4 years ago

Also quick question, what FPS are you getting on the SSD model?

I've never tested it out You can find some numbers here

https://coral.ai/docs/edgetpu/benchmarks/

danhartma commented 4 years ago

Hey everyone! Can you give more instructions on how to build this for arm64 devices with edgeTPU?

KyungWonPark commented 4 years ago

Hey everyone! Can you give more instructions on how to build this for arm64 devices with edgeTPU?

Hello... could you wait for coming weekend?... I think those issues might have been fixed so need to look into it again

danhartma commented 4 years ago

Hello and thanks for your response! Sure I can wait

zmajew commented 2 years ago

Checkout specified commit d855adfc5a0195788bf5f92c3c7352e638aa1109

$ git checkout d855adfc5a0195788bf5f92c3c7352e638aa1109

And build libtensorflow-lite.a and libtensorflowlite_c.so again.

Hi, so how to build from this commit? Since i requires 1.2.1 version of the bazel. I am not a C developer and I am stuck in the middle of the process. I have created shared libraries to run my binary, but when I tried to implement delegates I have lost the track at all. I am not even sure of the whole instalation workflow:

  1. Intall tensorflow lite?
  2. Than install libedgetpu?
  3. Than install edgetpu (to include edgetpu libraries inside of shared libraries libtensorflowlite_c.so)?
  4. Than setup env CGO_LDFLAGS to build the binary to the tenserflow_src?
  5. Than setup env CGO_CFLAGS the the location of the shared libraries so the binary can run?

My goal is to create builder docker image with Tensorflow Lite from who I can compile binary from my Golang code for Raspberry Pi aarch64. Can you help me with concrete workflow to install what is neaded to be able to implement your delegates library in my code?