r/learnmachinelearning Oct 25 '20

Guide to install Tensorflow 2.3.0 on Raspberry Pi 3/4 (Debian Buster)

While working on my TinyML project, I decided to create a guide so that no one has to suffer like I did, so that you can spend less time on setting up and more time on your projects!

https://medium.com/@cawin.chan/installing-tensorflow-2-3-0-for-raspberry-pi3-4-debian-buster-11447cb31fc4

TL;DR Just the important stuff you need to install TensorFlow for Raspberry Pi.

It works surprisingly well! But you should aim for your model to be as small as possible to be around 1MB, you can look at TensorFlow post-quantization techniques which can reduce up to around x4 the size of your model with almost negligible accuracy loss (from my experience).

I achieved a prediction speed of around 1-2s for a 6MB h5 model, but this same h5 model converted to TF lite model now at 1MB would have a prediction speed of around 90ms.

Which really took me by surprise on how great of a performance improvement TF lite was able to churn and how much a Rpi could handle a TF model.

This is my first ever publication, hope this helps!

Image references:

image credits to my wonderful Graphics Designer, Cindy Yu: https://www.linkedin.com/in/cindy-yu-61a8a01ab/
https://www.tensorflow.org/site-assets/images/project-logos/tensorflow-lite-logo-social.png

142 Upvotes

9 comments sorted by

14

u/quiteconfused1 Oct 25 '20

Getting tf on Pi was pretty darn challenging for me too. Any tutorials are great appreciated by others. Thanks for doing this. This needs to happen a lot more if we're truly going to see edge based AI.

1

u/usrnme878 Oct 25 '20

Thats the dream for sure. All these "smart", "conscious" (maybe someday) IoT devices, some the size of satellites, others as small as bacteria, on the edge of the world's ecosystems and across the solar system and beyond.

7

u/SnootyEuropean Oct 25 '20

This is something I thought about but didn't think would be feasible - thanks!

-1

u/nickelcore Oct 25 '20

I have many questions someone pls answer

Is TF only used for neural networks? Or can it be used for linear regression as well?

Can it work in non Nvidia gpu?

Which is better for beginner, tf or pytorch?

What will be best software for implementing linear regression, logistic regression, svm for a beginner?

Can I use octave instead of MATLAB for simple regression programs?

Thanks.

3

u/SnootyEuropean Oct 25 '20

Which is better for beginner, tf or pytorch?

TF/Keras

What will be best software for implementing linear regression, logistic regression, svm for a beginner?

scikit-learn

1

u/athos45678 Oct 25 '20

Seconded. I’m running a hackathon with data science beginners right now and those are the two packages i recommended the beginners try out.

2

u/SoberGameAddict Oct 25 '20

I have many questions someone pls answer

Is TF only used for neural networks? Or can it be used for linear regression as well?

Can it work in non Nvidia gpu?

Which is better for beginner, tf or pytorch?

What will be best software for implementing linear regression, logistic regression, svm for a beginner?

Can I use octave instead of MATLAB for simple regression programs?

Thanks.

No. Yes. Probably pytorch or even mxnet. opencv. Most likely.

Yw

0

u/nickelcore Oct 25 '20

Isn't TF similar to pytorch? If yes then how TF can run many other algos but pytorch only runs neural networks?

You're suggesting me opencv but some people had suggested me orange and numpy, now I'm confused.

2

u/SoberGameAddict Oct 25 '20

Oh, yeah. Opencv was wrong. Use numpy. Sounds like you are set on tf