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

OR Tools on Raspberry Pi 3 #510

Closed
hpswalters opened this issue Oct 23, 2017 · 7 comments
Closed

OR Tools on Raspberry Pi 3 #510

hpswalters opened this issue Oct 23, 2017 · 7 comments
Assignees
Labels
Feature Request Missing Feature/Wrapper Help Needed Modeling/Usage problem
Milestone

Comments

@hpswalters
Copy link

Laurent et al,
First I want to say how much I appreciate the tools here. I've been working exclusively in python and despite a number of issues, I did get a clean (from scratch starting with ubuntu 16) installation working on my laptop. Starting clean was surprisingly easy. That got me thinking--could I do the same on a Raspberry Pi 3? The answer is yes--with a few caveats. Things need to be installed that are RPI specific like ubuntu MATE for RPI 3 and CMAKE for RPI (There is one more tool that needs to be downloaded, but the name escapes me now..It is common and has appeared in the issues log numerous times). After the basic set up, your stuff can install your stuff from source. It is very time consuming but it works. No errors when running your "make test".

Unfortunately, when I run one of your samples, the job shop, it gives that pesky "ImportError: No module named ortools.constraint_solver". From reading other issues on the board, it appears that I should have made a change to a makefile with specifics regarding the PYTHONPATH and this would have placed those files in the appropriate place.

I can see from my successful ubuntu installation that I have in the /usr/local/lib/python2.7/dist-packages directory three subdirectories from your installation routine - ortools, ortools-6.5.4527-dist-info and google. The RPI installation does not have these in those locations so clearly I missed something.

Well, what's done is done and I'm so close that I can taste it. So two questions:

  1. "make test" worked even if it did take a long time to run. I don't know if the answers to the examples were right but it was clearly working. In my mind, I should be able to replicate the way these programs were running. I think it may be as easy as running from a specific directory.
    Do you know what this would be?

  2. If I was going to do this the right way, I'd rerun the whole thing, clean. Since I will probably do this, I need to know which makefile (and where I find it) to adjust the PYTHONPATH.

If this works it, I think it could be of considerable assistance. Since the RPI3 and a 16 gb memory disk are so inexpensive, it is reasonable for anyone to have a dedicated optimization server. In addition, most of this is so lite, you can publish and entire installation, ubuntu and all, with a single image file. I could see different .img files for each language python, c++, java, and perhaps even c#. It could save a lot of hassles to have an installation out of the box

@orwant
Copy link
Collaborator

orwant commented Nov 12, 2017 via email

@lperron
Copy link
Collaborator

lperron commented Nov 13, 2017 via email

@hpswalters
Copy link
Author

Jon, Laurent,
Thanks for your interest. I have achieved some success and have a working version on the raspberry pi. I’ve done this multiple times and have been able to follow Laurent’s instructions without too many refinements. It’s pretty cool, really. The main problem was locating all the ortool modules. No matter what I did to PYTHONPATH The performance aspect is about where I expected: the rpi is about 1/5 to 1/8 the speed of my laptop (a gen 2 i7).

Ideally, I would like to image the sd card, hand it over to you guys. You can publish a 8 GB file that people can download, install on an sd card, insert in an rpi and off you go.

I should have instructions out this weekend

@hpswalters
Copy link
Author

Jon and Laurent,
Here are the instructions for getting or-tools running on a raspberry pi 3

instructions for using Or-Tools on a raspberry pi 3 with python
Do everything as the superuser (sudo)
User is pi
Logon is raspberry
However, you will want to boot to the UI with automatic logon

  1. Download NOOBS onto your windows computer.
  2. Unpack it on your hard drive and copy to a 16GB micro SD. You can get a bigger one, but smaller (8GB) seems to give the raspberry pi problems because of the space this process takes up.
  3. Place the SD card in the raspberry pi and plug it in. There is no on or off switch that comes with the raspberry pi. From experience, it should be unplugged after it is shutdown. In addition, a user should always shutdown using sudo shutdown now from the command line or selecting it from the GUI. Interrupting the power can corrupt the SD card.
  4. on bootup you will be taken to a setup window. Select the "Raspbian with desktop" option not the "Raspbian lite" version. It is typically the first in the list. This installation comes with versions of IDLE for python 2 (2.6, 2.7) and Python 3 (3.5)
  5. Optional - remove libreoffice, wolfram-engine, sonic-pi, scratch – it saves a little space not too much
    a. sudo apt-get purge libreoffice wolfram-engine sonic-pi scratch
    b. sudo apt-get autoremove

This sets the base installation for the raspberry pi. From here follow the instructions on the site

  1. Install the C++ prerequisites - sudo apt-get -y install git autoconf libtool zlib1g-dev gawk g++ curl cmake subversion make lsb-release

  2. Install swig - sudo apt-get -y install swig

  3. Install tools for python (2 in my case) – these should already be the latest versions but it never hurts to perform the step - sudo apt-get -y install python-dev python-setuptools python-six

  4. Generate the git clone in /usr/lib/python2.7
    a. cd /usr/lib/python2.7
    b. sudo git clone –recursive https://github.com/google/or-tools.git

  5. cd /usr/lib/python2.7/or-tools

  6. sudo make third-party > /home/pi/make_third_party.txt
    You will get a strange message Makefile:43 … - Don’t panic the process will continue although it takes a while so go make a sandwich

  7. sudo make python – Go make a snack because this takes a while, too

  8. sudo make test

  9. Copy init.py and init.pyc files
    a. cd /usr/lib/python2.7/or-tools/ortools
    b. sudo cp init.p* /usr/lib/python2.7
    c. sudo cp init.p* /usr/lib/python2.7/or-tools

  10. Copy the examples to /home/pi. Delete the ones you will not use.

  11. To run example or your own files you will need to preface each script with:
    a. import sys
    b. sys.path.append(r’/usr/lib/python2.7’)
    c. sys.path.append(r’/usr/lib/python2.7/or-tools’)

This needs to be before the line that import of one of the or tools wrappers

If it is helpful I can publish an img file that people can download. It would take about 16GB

Performance:
The raspberry pi 3 is slower than my laptop (2nd generation i7) by a factor of 5 to 10 depending on the problem and the solver library

@lperron
Copy link
Collaborator

lperron commented Nov 23, 2017

Thanks!!!

We need time to digest it and replicate it :-)

@hpswalters
Copy link
Author

hpswalters commented Nov 23, 2017 via email

@Mizux Mizux self-assigned this Jan 2, 2018
@Mizux Mizux added the Feature Request Missing Feature/Wrapper label Jan 2, 2018
@Mizux Mizux added the Help Needed Modeling/Usage problem label Mar 9, 2018
@Mizux Mizux added this to the Backlog milestone Mar 12, 2018
@lperron
Copy link
Collaborator

lperron commented Aug 6, 2019

Not supported in the current build,
Not planned for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature Request Missing Feature/Wrapper Help Needed Modeling/Usage problem
Projects
None yet
Development

No branches or pull requests

4 participants