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

TensorFlow C binding for Raspberry Pi #30359

Open
marianopeck opened this issue Jul 3, 2019 · 16 comments
Open

TensorFlow C binding for Raspberry Pi #30359

marianopeck opened this issue Jul 3, 2019 · 16 comments

Comments

@marianopeck
Copy link

@marianopeck marianopeck commented Jul 3, 2019

System information

  • TensorFlow version (you are using): 1.13.1
  • Are you willing to contribute it (Yes/No): yes, at least as a tester

Describe the feature and the current behavior/state.
I asked on StackOverflow if there was a TensorFlow C binding for ARM/RaspberryPi but I got no answer after many days.

I couldn't find anything on the website, so I suspect this is not yet available?

If it is just a matter that you don't distribute the binaries, I have no troubles to compile it myself if I have the instructions and if it is known to work. But I haven't found anything confirming that either.

Will this change the current api? How?
No

Who will benefit with this feature?
All language bindings that use the C library and want to run on any ARM board

Any Other info.

@freedomtan

This comment has been minimized.

Copy link
Contributor

@freedomtan freedomtan commented Jul 3, 2019

The last paragraph of the "TensorFlow for C" you cited points to a how-to file which does show you how to build TensorFlow C API from source code with bazel

@marianopeck

This comment has been minimized.

Copy link
Author

@marianopeck marianopeck commented Jul 3, 2019

Thanks @freedomtan. I didn't know if something special compilation was needed for ARM. Are you aware of people/projects compiling it and using successfully?

@freedomtan

This comment has been minimized.

Copy link
Contributor

@freedomtan freedomtan commented Jul 5, 2019

@marianopeck something like

CC=clang-6.0 CXX=clang++-6.0 \
bazel build --config opt --local_resources 1024.0,0.5,0.5 \
--copt=-mfpu=neon-vfpv4 \
--copt=-ftree-vectorize \
--copt=-funsafe-math-optimizations \
--copt=-ftree-loop-vectorize \
--copt=-fomit-frame-pointer \
--copt=-DRASPBERRY_PI \
--host_copt=-mfpu=neon-vfpv4 \
--host_copt=-ftree-vectorize \
--host_copt=-funsafe-math-optimizations \
--host_copt=-ftree-loop-vectorize \
--host_copt=-fomit-frame-pointer \
--host_copt=-DRASPBERRY_PI \
//tensorflow/tools/lib_package:libtensorflow

works for me.

@ravikyram

This comment has been minimized.

Copy link

@ravikyram ravikyram commented Jul 9, 2019

@marianopeck Just to verify did you get a chance to follow instructions as suggested by freedomtan .Thanks!

@marianopeck

This comment has been minimized.

Copy link
Author

@marianopeck marianopeck commented Jul 9, 2019

Hi @ravikyram
Not yet. I will see if I can try it this week.
BTW, if there is a compilation instruction and people claim it works, any reason why the binaries are not officially distributed as the rest of the "TensorFlow for C"?

@marianopeck

This comment has been minimized.

Copy link
Author

@marianopeck marianopeck commented Jul 12, 2019

Hi @freedomtan
Which version did you use? It's 2.0? Or older too? I would like to try with 1.13.1 or similar.
Thanks

@freedomtan

This comment has been minimized.

Copy link
Contributor

@freedomtan freedomtan commented Jul 12, 2019

@marianopeck I use master branch most of the time. I think it works on TensorFlow versions before 1.10 to current master.

@marianopeck

This comment has been minimized.

Copy link
Author

@marianopeck marianopeck commented Jul 12, 2019

Hi @freedomtan
Thanks, I am trying now to compile it myself but I wasn't even able to compile bazel on the first place :( I am getting this issue: bazelbuild/bazel#8882
If I am able to pass that, I will continue..

@freedomtan

This comment has been minimized.

Copy link
Contributor

@freedomtan freedomtan commented Jul 12, 2019

@marianopeck I haven't tried newer bazel, general comment is to increase your swap space and maximum Java heap size (e.g., -J-Xmx1024m instead of -J-Xmx512m)

@marianopeck

This comment has been minimized.

Copy link
Author

@marianopeck marianopeck commented Jul 17, 2019

Hi, as I found no binary available, I had to manage myself.
I finally took the time to write down everything I found during my attempt to get TensorFlow C library compiled for Raspberry Pi. In that tutorial, I point back to this issue in case any progress is made.
Thank you

@freedomtan

This comment has been minimized.

Copy link
Contributor

@freedomtan freedomtan commented Jul 18, 2019

good to see another effort on Smalltalk + TensorFlow. Smalltalk is one of my favorite language. I tried Pharo bindings for TensorFlow before and was able to use both TensorFlow C API and TensorFlow Lite C API on x86 machines

@marianopeck

This comment has been minimized.

Copy link
Author

@marianopeck marianopeck commented Jul 18, 2019

Hi @freedomtan
We are in the same boat then :) That's great to hear. The Pharo bindings are actually a port made by @SergeStinckwich from the work done on Cuis Smalltalk. The latter was mostly done by @gerasdf and he is now doing most of the port to VASmalltalk.
I am interested in hearing about your experiments. To avoid making noise in this issue, I will send you an email.
Thanks!

@SergeStinckwich

This comment has been minimized.

Copy link

@SergeStinckwich SergeStinckwich commented Jul 18, 2019

hi @marianopeck, @freedomtan already have done some contributions to the Pharo port.
Yes all on the same boat, let's try to go in the same direction :-) Let's discuss about that in ESUG 2019 ?

@marianopeck

This comment has been minimized.

Copy link
Author

@marianopeck marianopeck commented Jul 18, 2019

OK, I sent you both and the rest of the involved parts a private email to so that we can continue discussing :)

@PINTO0309

This comment has been minimized.

Copy link

@PINTO0309 PINTO0309 commented Jul 20, 2019

Although I do not have C language implementation skills, I tried to generate a binary for RaspberryPi of Tensorflow v1.14.0. I have not confirmed the operation.
https://github.com/PINTO0309/Tensorflow-bin.git
https://github.com/PINTO0309/Tensorflow-bin/tree/master/C-library/1.14.0-armv7l

@marianopeck

This comment has been minimized.

Copy link
Author

@marianopeck marianopeck commented Jul 21, 2019

That worked perfectly!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
6 participants
You can’t perform that action at this time.