ludwig-ai / ludwig

Low-code framework for building custom LLMs, neural networks, and other AI models
http://ludwig.ai
Apache License 2.0
11.1k stars 1.19k forks source link

Ability to be installed on armv7 (raspberry pi) #301

Open vegeta340 opened 5 years ago

vegeta340 commented 5 years ago

As a: creator

I want to: use Ludwig for making decisons on rpi3b+

then: Ludwig will be able to interact with real world.

i tried install it more than three weeks without success.

I am able to install requirements separately but not by using pip3 (auto and manual mode). I was not able to install tensorflow and blis on raspbian stretch which is needed to install h5py because standard raspbian was out of memory in this case.

I know that operation is hard but it will open completely new possibilities of Ludwig usage. It will be the best uber product.

AWS Rekognition was also considered for the same purpose (pictures classification with low latency) but then rpi needs to be always connected to internet what is just wrong.

If you will be able to help me (it is really hard journey) with this idea then I could share with you how i want to use it. ;)

w4nderlust commented 5 years ago

@vegeta340 this is cool, it would be great if we could make Ludwig run on a raspberry! Not sure what the latency would be, but if the model is small enough it maybe not super horrible (although I'm not sure about TF's optimization for arm, but I guess tflite can come to the rescue). The problem is i don't have one and i don't have experience with armv7 architectures, so I'm not sure how much of a help I could be. Anyway, let's discuss this and let's try to do what's possible.

First thing, this is a call to harms for people with experience with raspberry, tagging this post with the Help Needed badge.

Second, from your description it looks like the problem is mostly with installing the dependencies more than with Ludwig itself: h5py and tensorflow. Searching on the web this solution appears for tensorflow and this one for h5py. Let me know if by doing so you can get further.

vegeta340 commented 5 years ago

@w4nderlust:

H5py is installable on raspbian stretch but not on standard raspbian probably because of intensive ram usage. When GUI is installed then h5py installation fails. Without GUI everything is ok with this module.

Tensorflow is installable on standard raspbian (latest build is 1.10) but i am unable to install it on raspbian stretch. I also tried building it on rpi but it needs Bazel, what also needs to be built, but it needs modified gcc compiler and it is not buildable on raspberry with stretch so maybe tf-lite will be the solution here.

Blis is just not installable on every kind of raspbian. I use the system image with spaCy (raspbian stretch image: https://github.com/explosion/spaCy/issues/2889 ), where blis should be included (it is in spaCy requirements) but pip3 during Ludwig requirements installation still want to install spaCy with Blis what is the reason of overall failure.

I didn't try to install ludwig without requirements. If someone will be able to modify Ludwig requirements to be compatible with rpi or provide system image with installed ludwig then issue could be closed.

Lack of Rpi is easy to fix by me, you just need to send me the delivery address. ;) Otherwise i could share with you ssh connection to my rpi.

w4nderlust commented 5 years ago

Got it, thanks for the details.

I guess one thing you could try is to install Ludwig by cloning the repo and running setup.py. That allows you to change the requirements before installing it (for instance removing line 49 from setup.py), and remove spaCy. At the moment spaCy provides some advances tokenizers for text, so if you don't need / use them this should be fine. Let me know if this helps.

Regarding tf-lite, I've never used it, so investigating it would be interesting. Anyway, I believe I may be using some features from tf 1.12 and 1.13, so if the latest tf available to you is 1.10, there may be some issues with different method signatures. In that case, the ideal would be to compile tf 1.13, but as you said, bazel is needed for doing that. I don't really know the answer here, maybe someone else with more experience on raspberry can help on this.

vegeta340 commented 5 years ago

Hi,

i will try installation without spaCy, it will be very helpful. Text recognition could be added later. Tensorflow is a issue here but i will try to install tf-lite on rpi and then let you know about the results.

vegeta340 commented 5 years ago

So I have installed Ludwig (with full Tensorflow 1.13.1 and without spaCy), installation with edited setup.py was done after first installation without edited setup.py if this could matter in this case. Model was trained on laptop (images classification) but when I want to use ludwig prediction abilities on Raspbian then I receive error: "raise DistributionNotFound: The 'spacy>=2.1' distribution not found and is required by ludwig"

screenshot: https://ibb.co/DgSk5CS

Is it hard to remove this dependency?

w4nderlust commented 5 years ago

Can you provide the full error? There shouldn't be the need for spacy to be there if you are not using a text feature with one of the spacy tokenizers, so i want to understand where is this problem coming from, what function raises the error, as I'm not raising it myself in the code. The place where I specify spacy>=2.1 is in requirements.txt and setup.py and nowhere else, so if you removed spacy from there as I was suggesting there shouldn't be any problem, because import spacy is only done in utils/nlp_utils.py which in turn is used only if you specify a spacy based tokenizer for a text feature.

vegeta340 commented 5 years ago

You can find a link to screenshot with full error message in earlier post. I will try install ludwig once again from scratch, overwriting of existing installation probably was not a good idea. We will know!

w4nderlust commented 5 years ago

mmm what that is telling me is that the package still expects spacy. You should remove it from both requirements.txt and setup.py, make sure you do it before you build the package. Let me know (pretty cool to see it called from a raspberry anyway!).

Also, it could be the case that the ludwig command was built previously, with the older package which contained the depepndency. Make sure you uninstall Ludwig entirely before installing the new package. Another option you have is to use python -m ludwig.predict ... instead, which does not use the entry point, so if you have the wrong command in /bin/ludwig it should bypass it.