Xgboost installation on Mac - python

I am trying to install xgboost on my mac (10.12.5) and after several attempts I did not succeed. I follow different tuto trying to modifi gcc variable by adding gcc-6 but I have the same problem.
So what I did:
git clone --recursive https://github.com/dmlc/xgboost
cd xgboost; cp make/minimum.mk ./config.mk; make -j4
I have the following error:
/usr/local/bin/g++ -std=c++11 -Wall -Wno-unknown-pragmas -Iinclude -Idmlc-core/include -Irabit/include -I/include -O3 -funroll-loops -msse2 -fPIC -DDISABLE_OPENMP -MM -MT build/learner.o src/learner.cc >build/learner.d
/usr/local/bin/g++ -std=c++11 -Wall -Wno-unknown-pragmas -Iinclude -Idmlc-core/include -Irabit/include -I/include -O3 -funroll-loops -msse2 -fPIC -DDISABLE_OPENMP -MM -MT build/logging.o src/logging.cc >build/logging.d
/usr/local/bin/g++ -std=c++11 -Wall -Wno-unknown-pragmas -Iinclude -Idmlc-core/include -Irabit/include -I/include -O3 -funroll-loops -msse2 -fPIC -DDISABLE_OPENMP -MM -MT build/c_api/c_api.o src/c_api/c_api.cc >build/c_api/c_api.d
/usr/local/bin/g++ -std=c++11 -Wall -Wno-unknown-pragmas -Iinclude -Idmlc-core/include -Irabit/include -I/include -O3 -funroll-loops -msse2 -fPIC -DDISABLE_OPENMP -MM -MT build/c_api/c_api_error.o src/c_api/c_api_error.cc >build/c_api/c_api_error.d
/bin/sh: /usr/local/bin/g++: No such file or directory
/bin/sh: /usr/local/bin/g++: No such file or directory
make: *** [build/learner.o] Error 127
make: *** Waiting for unfinished jobs....
/bin/sh: /usr/local/bin/g++: No such file or directory
make: *** [build/logging.o] Error 127
make: *** [build/c_api/c_api.o] Error 127
/bin/sh: /usr/local/bin/g++: No such file or directory
make: *** [build/c_api/c_api_error.o] Error 127
My gcc version is:
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 8.1.0 (clang-802.0.42)
Target: x86_64-apple-darwin16.6.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
I really need your help. For the moment I use pip install xgboost to use the library but I know it's not the right way to use this library.
Thank you for your help
ps: sorry if my english is not ok, i am not fluent

Using Docker images helps the best in such cases since it encapsulates the environment. You can install Docker from here. If you want to work using xgboost library, you can pull image using the following command,
docker pull datmo/xgboost:cpu
After this, you can run containers using this image and mount necessary files in order to run the same environment.
You can also use datmo CLI in order to easily setup environment and also version control your machine learning models.

Try This it worked for
$ brew install gcc-5
$ brew install cmake
$ pip install xgboost

I was able to install xgboost on my mac by using conda.
Try "conda install py-xgboost". This worked for me.

Related

fatal error: 'fst/types.h' file not found

I'm trying to install openfst like so:
wget http://www.openfst.org/twiki/pub/FST/FstDownload/openfst-1.8.2.tar.gz
tar zxvf openfst-1.8.2.tar.gz
cd openfst-1.8.2
./configure --enable-python
make
sudo make install
but during the Python installation step, I get:
Making install in python
/bin/sh ../../../libtool --tag=CXX --mode=compile g++ -std=c++17 -fno-exceptions -Wno-deprecated-declarations -DHAVE_CONFIG_H -I./../../include -I/Users/colin/opt/miniconda3/envs/logos/include/python3.8 -fexceptions -g -O2 -MT pywrapfst_la-pywrapfst.lo -MD -MP -MF .deps/pywrapfst_la-pywrapfst.Tpo -c -o pywrapfst_la-pywrapfst.lo `test -f 'pywrapfst.cpp' || echo './'`pywrapfst.cpp
libtool: compile: g++ -std=c++17 -fno-exceptions -Wno-deprecated-declarations -DHAVE_CONFIG_H -I./../../include -I/Users/colin/opt/miniconda3/envs/logos/include/python3.8 -fexceptions -g -O2 -MT pywrapfst_la-pywrapfst.lo -MD -MP -MF .deps/pywrapfst_la-pywrapfst.Tpo -c pywrapfst.cpp -fno-common -DPIC -o .libs/pywrapfst_la-pywrapfst.o
pywrapfst.cpp:643:10: fatal error: 'fst/types.h' file not found
#include <fst/types.h>
^~~~~~~~~~~~~
1 error generated.
I don't really understand why, given that seemingly we just installed the necessary fst components?
Is this an issue with the conda installation or something else?
I'm using Miniconda with conda version 4.13.0
Any pointers would be appreciated!
I think the problem is the openfst itself:
OpenFst no longer produces a fst/types.h
If you just want to use wrapped python or not a C++ dev, you should use anaconda package: OpenFST anaconda as #kotatsuyaki suggest. Or you can install from source with version 1.7.x

Preventing spurious -m32 flag when running running setup.py build_ext

I'm trying to cross-compile numpy for arm (BeagleBone & RPi). I am running on debian buster, with a 32bit cross-compilation toolchain, including i386 (32bit) libraries and all necessary arm toolchains.
When I run:
export CC=arm-linux-gnueabihf-gcc CXX=arm-linux-gnueabihf-g++ AR=arm-linux-gnueabihf-ar RANLIB=arm-linux-gnueabihf-ranlib; \
python3 setup.py build_ext --inplace
I get the following error:
C compiler: arm-linux-gnueabihf-gcc -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -m32 -I/usr/include/i386-linux-gnu/ -m32 -I/usr/include/i386-linux-gnu/ -fPIC
compile options: '-Inumpy/core/src/common -Inumpy/core/src -Inumpy/core -Inumpy/core/src/npymath -Inumpy/core/src/multiarray -Inumpy/core/src/umath -Inumpy/core/src/npysort -I/usr/local/include/python3.7m -c'
arm-linux-gnueabihf-gcc: _configtest.c
arm-linux-gnueabihf-gcc: error: unrecognized command line option ‘-m32’; did you mean ‘-mbe32’?
I've traced through numpy's setup.py file and found that ultimately these settings seem to be generated in the distutils.core._setup_distribution.get_command_obj("build") call.
The error is quite self explanatory, and trying to run the command without the -m32 flags seems to work correctly.
Edit: further digging has revealed that these parameters come to the build script via:
sysconfig.get_config_var("LDSHARED")
I'm still stumped because the following still doesn't work:
$LDSHARED="gcc -pthread -shared" python3 -c "import sysconfig; print(sysconfig.get_config_var('LDSHARED'))"
gcc -pthread -shared -m32 -m32
Turns out this LDSHARED parameter is coming from the Makefile that was used during the build of the python host itself. Under most scenarios it makes sense to have it this way, but a combination of cross-compiling and the arm gcc not accepting that flag made it problematic...
This may very well be unresolvable and I have instead resorted to capturing the parameter from the gcc itself via a symlink/bash script.

"python setup.py install" custom dependency location

I'm currently trying to install a custom version of pyyaml linked with libyaml to test how my code execution time might benefit from the extra performance offered (as suggested in https://pyyaml.org/wiki/PyYAMLDocumentation). I've installed libyaml as described in the documentation
./bootstrap && ./configure --prefix /my/install/location
but when I run the install for pyyaml
python setup.py --with-libyaml install
I get
creating build/temp.linux-x86_64-2.7/ext
/usr/bin/gcc -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/usr/bin/python2.7 -c ext/_yaml.c -o build/temp.linux-x86_64-2.7/ext/_yaml.o
gcc: error: ext/_yaml.c: No such file or directory
gcc: fatal error: no input files
How do I point the install to /my/install/location? Is there a way to extend the search path to include the extra location, or is there another way that this should be brought together?

boost python library linking issue -- undefined symbol

I am using boost-python built for python3 to expose a simple hello-world program. The example can be found here : https://github.com/TNG/boost-python-examples/blob/master/01-HelloWorld/hello.cpp
I ran the following commands to get the shared object:
g++ -fPIC -c -I/usr/include/python3.4m -I/usr/include/python3.4m -Wno-unused-result -g -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -L/usr/lib/x86_64-linux-gnu/libboost_python-py34 hello.cpp
g++ -shared hello.o -o hello.so
After this, I run the python3 -c 'import hello' command and I get the following error:
Traceback (most recent call last):
File "", line 1, in
ImportError: hello.so: undefined symbol: _ZTIN5boost6python7objects21py_function_impl_baseE
I partly understand this issue may be because my boost-python installation may be built for an alternative python version (for instance python2.7). When I run the command:
ls /usr/lib/x86_64-linux-gnu/libboost_python*.so
There are three .so files:
1. libboost_python-py27.so
2. libboost_python-py34.so
3. libboost_python.so
How can this issue be circumvented?
use pkg-config to retrieve ldflags and cflags of your boost library
Installing miniconda might be an option for you. https://conda.io/miniconda.html
This will provide a complete, isolated, python environment. You can then
conda install boost
I've tested this on my system and it worked well. I modified the Makefile from http://www.shocksolution.com/python-basics-tutorials-and-examples/linking-python-and-c-with-boostpython/
My Makefile can be found here:
https://github.com/grelleum/boost-python-with-anaconda

XGBoost installation via Anaconda 1.5.1 fails on OS X

I have GCC installed via Homebrew using brew install gcc --without-multilib. When I tried to use pip install xgboost in Anaconda 1.5.1 on OS X El Capitan 10.11.6 and Conda 4.1.11 running Python 3.5.2, I get the following output and error:
Collecting xgboost
Using cached xgboost-0.6a2.tar.gz
Complete output from command python setup.py egg_info:
rm -f -rf build build_plugin lib bin *~ */*~ */*/*~ */*/*/*~ */*.o */*/*.o */*/*/*.o xgboost
clang-omp++ -std=c++0x -Wall -O3 -msse2 -Wno-unknown-pragmas -funroll-loops -Iinclude -Idmlc-core/include -Irabit/include -fPIC -fopenmp -MM -MT build/learner.o src/learner.cc >build/learner.d
/bin/sh: clang-omp++: command not found
clang-omp++ -std=c++0x -Wall -O3 -msse2 -Wno-unknown-pragmas -funroll-loops -Iinclude -Idmlc-core/include -Irabit/include -fPIC -fopenmp -MM -MT build/logging.o src/logging.cc >build/logging.d
make: *** [build/learner.o] Error 127
make: *** Waiting for unfinished jobs....
/bin/sh: clang-omp++: command not found
make: *** [build/logging.o] Error 127
-----------------------------
Building multi-thread xgboost failed
Start to build single-thread xgboost
rm -f -rf build build_plugin lib bin *~ */*~ */*/*~ */*/*/*~ */*.o */*/*.o */*/*/*.o xgboost
clang-omp++ -std=c++0x -Wall -O3 -msse2 -Wno-unknown-pragmas -funroll-loops -Iinclude -Idmlc-core/include -Irabit/include -fPIC -fopenmp -MM -MT build/learner.o src/learner.cc >build/learner.d
/bin/sh: clang-omp++: command not found
make: *** [build/learner.o] Error 127
make: *** Waiting for unfinished jobs....
clang-omp++ -std=c++0x -Wall -O3 -msse2 -Wno-unknown-pragmas -funroll-loops -Iinclude -Idmlc-core/include -Irabit/include -fPIC -fopenmp -MM -MT build/logging.o src/logging.cc >build/logging.d
/bin/sh: clang-omp++: command not found
make: *** [build/logging.o] Error 127
Successfully build single-thread xgboost
If you want multi-threaded version
See additional instructions in doc/build.md
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/private/var/folders/94/yw1tx2t95lb31nlww2nwpk114lvh7b/T/pip-build-k_1ed1r6/xgboost/setup.py", line 29, in <module>
LIB_PATH = libpath['find_lib_path']()
File "/private/var/folders/94/yw1tx2t95lb31nlww2nwpk114lvh7b/T/pip-build-k_1ed1r6/xgboost/xgboost/libpath.py", line 45, in find_lib_path
'List of candidates:\n' + ('\n'.join(dll_path)))
XGBoostLibraryNotFound: Cannot find XGBoost Libarary in the candicate path, did you install compilers and run build.sh in root path?
List of candidates:
/private/var/folders/94/yw1tx2t95lb31nlww2nwpk114lvh7b/T/pip-build-k_1ed1r6/xgboost/xgboost/libxgboost.so
/private/var/folders/94/yw1tx2t95lb31nlww2nwpk114lvh7b/T/pip-build-k_1ed1r6/xgboost/xgboost/../../lib/libxgboost.so
/private/var/folders/94/yw1tx2t95lb31nlww2nwpk114lvh7b/T/pip-build-k_1ed1r6/xgboost/xgboost/./lib/libxgboost.so
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/94/yw1tx2t95lb31nlww2nwpk114lvh7b/T/pip-build-k_1ed1r6/xgboost/
I solved this by following the Python Package Installation instructions. I now have the package without a pip installation.

Categories

Resources