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

Installing XGboost in a Raspberry-pi #2012

Closed
ghost opened this issue Feb 5, 2017 · 8 comments
Closed

Installing XGboost in a Raspberry-pi #2012

ghost opened this issue Feb 5, 2017 · 8 comments

Comments

@ghost
Copy link

ghost commented Feb 5, 2017

Hi,

I trained a model in a computer and now I am trying to put it in a r-pi, but I am not able to download the package. My intention is only to predict some values using the model, built in a more powerful pc.

I did follow the two possible ways recommended in the Github but I failed in both. I copy all the methods and errors obtained:

From the Github

My steps here are a mix of some steps I read:

git clone --recursive https://github.com/dmlc/xgboost
cd xgboost

I read to modify the Makefile by deleting -msse2 flag, and I did it to allow make command to be launched. After that I did:

cp make/minimum.mk ./config.mk
make -j4
sudo ./build.sh
cd python-package
sudo python setup.py install

And the results obtained:

pi@raspberrypi:~/xgboost/python-package $ sudo python setup.py install
Traceback (most recent call last):
  File "setup.py", line 19, in <module>
    LIB_PATH = [os.path.relpath(libfile, CURRENT_DIR) for libfile in libpath['find_lib_path']()]
  File "xgboost/libpath.py", line 46, in find_lib_path
    'List of candidates:\n' + ('\n'.join(dll_path)))
__builtin__.XGBoostLibraryNotFound: Cannot find XGBoost Library in the candidate path, did you install compilers and run build.sh in root path?
List of candidates:
/home/pi/xgboost/python-package/xgboost/libxgboost.so
/home/pi/xgboost/python-package/xgboost/../../lib/libxgboost.so
/home/pi/xgboost/python-package/xgboost/./lib/libxgboost.so
/usr/xgboost/libxgboost.so

Thanks in advance

@tqchen
Copy link
Member

tqchen commented Feb 5, 2017

remove -msse2 flag in compilation

@ghost
Copy link
Author

ghost commented Feb 5, 2017

That's what I did before @tqchen. The output after the sudo python setup.py install is the one in the question
Thanks

@tqchen
Copy link
Member

tqchen commented Feb 6, 2017

make sure you can xgboost library build outputted in the candidate path, it is likely that the build is not successful

@phunterlau
Copy link
Contributor

I think the problem comes from 'sudo build.sh': you don't have to 'sudo', otherwise it may build the .so somewhereelse

@phunterlau
Copy link
Contributor

Forgot to mention: just make with the modified .mk, no need to run 'build.sh' since it just calls make again

@ghost
Copy link
Author

ghost commented Feb 6, 2017

Okay, thanks for your answers @tqchen and @phunterlau , but problem is still there. Now I am trying to install it at /usr/lib/python2.7/dist-packages/ from Git.

Even following the steps, the error is still the same:

pi@raspberrypi:/usr/lib/python2.7/dist-packages/xgboost/python-package $ sudo python setup.py install
Traceback (most recent call last):
  File "setup.py", line 19, in <module>
    LIB_PATH = [os.path.relpath(libfile, CURRENT_DIR) for libfile in libpath['find_lib_path']()]
  File "xgboost/libpath.py", line 46, in find_lib_path
    'List of candidates:\n' + ('\n'.join(dll_path)))
__builtin__.XGBoostLibraryNotFound: Cannot find XGBoost Library in the candidate path, did you install compilers and run build.sh in root path?
List of candidates:
/usr/lib/python2.7/dist-packages/xgboost/python-package/xgboost/libxgboost.so
/usr/lib/python2.7/dist-packages/xgboost/python-package/xgboost/../../lib/libxgboost.so
/usr/lib/python2.7/dist-packages/xgboost/python-package/xgboost/./lib/libxgboost.so
/usr/xgboost/libxgboost.so

@mkjiang
Copy link

mkjiang commented Mar 24, 2017

Hello @xrr47, not sure if you've figured out the problem by now but I faced the same issue when compiling mine.

Apparently the build was reported as "successful" but actually not so. If you look at your compile log carefully you should see errors like,

warning: no files found matching '*' under directory 'xgboost/include'
warning: no files found matching '*' under directory 'xgboost/src'
warning: no files found matching '*' under directory 'xgboost/make'
warning: no files found matching '*' under directory 'xgboost/rabit'
warning: no files found matching '*' under directory 'xgboost/lib'
warning: no files found matching '*' under directory 'xgboost/dmlc-core'
warning: no previously-included files matching '*.o' found anywhere in distribution
warning: no previously-included files matching '*.a' found anywhere in distribution
warning: no previously-included files matching '*.pyo' found anywhere in distribution
warning: no previously-included files matching '*.pyc' found anywhere in distribution 

That means your build did not include the necessary libraries thus your reported error.

Strangely this issue was supposedly fixed in #1932 but I still do not see the mentioned folders under xgboost/python-packages/, only under the main xgboost/ which is one level up. So I symlinked them and the build was completed without complaining, well, apart from no pyo and pyc files found.

I could then import xgboost in Jupyter and read in data via xgb.DMatrix but as soon as I start training the kernel crashes without giving an error. Any ideas? @tqchen @phunterlau

@mweber-ovt
Copy link

mweber-ovt commented Jan 14, 2018

I figured it out. Below are step-by-step instructions that work as of today (Jan 14 2018) to install XGBoost for Python 3 on a Raspberry Pi 3 with the newest Raspian version (stretch).

First, update your system's package list by entering the following command:
sudo apt-get update
Next, upgrade all your installed packages to their latest versions with the command:
sudo apt-get dist-upgrade
Make sure the needed Python tools are installed:
sudo apt-get install python-setuptools

Then, in principle, you can follow the instructions here for Debian/Ubuntu:
http://xgboost.readthedocs.io/en/latest/build.html
However, an edit is necessary to one of the make files.

First, clone the GIT directory:
git clone --recursive https://github.com/dmlc/xgboost

In the subdirectory/xgboost/rabit/, edit Makefile, line 22, to get rid if the -msse2 flag. It should simply read:
export CFLAGS = -O3 $(WARNFLAGS)

Change back to the xgboost subdirectory, and type:
make -j4
During the make, the RPi2 will run on all barrels and may get too hot and freeze. That happened to me during the process. I had to open the box I have it in and blow at it with a fan!

To make and install the Python package (use Python3 to be sure it installs to the right Python):
cd python-package; sudo python3 setup.py install

@tqchen tqchen closed this as completed Jul 4, 2018
@lock lock bot locked as resolved and limited conversation to collaborators Oct 24, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants