您的位置:首页 > 其它

Ubuntu安装xgboost

2016-08-07 11:04 295 查看
实验室集群上需要安装xgboost,先把它连同submodule一起clone下来

git clone --recursive https://github.com/dmlc/xgboost然后 cd xgboost,执行make,若想加快编译速度,对于多核CPU,可以make -j4,
编译后会在xgboost/lib目录生成libxgboost.a和.so文件

随后是安装python的模块,主要看这么两种方式:

cd python-package; sudo python setup.py install这种方式是将python模块加载到系统路径上

另外一种方式是

export PYTHONPATH=~/xgboost/python-package这样是将当前python包的路径加到PYTHONPATH中,系统以后能找到
对于开发者,推荐第二种方式,因为第一种方式当你改变了代码后,又得install一遍。这里我们也用的export的方式

然后python -c "import xgboost as xgb"提示说缺少scipy的模块,说明当前系统还没安装scipy

下面是安装scipy:

git clone git://github.com/scipy/scipy.git scipy

cd scipy, 执行

python setup.py install


提示说

ImportError: No module named Cython.Compiler.Main
Exception: Cython either isn't installed or it failed.
Traceback (most recent call last):
File "setup.py", line 415, in <module>
setup_package()
File "setup.py", line 399, in setup_package
generate_cython()
File "setup.py", line 205, in generate_cython
raise RuntimeError("Running cythonize failed!")
RuntimeError: Running cythonize failed!
即 要先安装Cpython

看网上的文档说,scipy依赖lapack, nose, atlas等包,安装一套流程下来确实比较繁琐,我不确定自己的集群上是否已经安装好了可以被scipy用的atlas,正在观望时,到scipy的官网上看了一下介绍,对于ubuntu&debian系统,可以用安装好一套scipy stack:

sudo apt-get install python-numpy python-scipy python-matplotlib ipython ipython-notebook python-pandas python-sympy python-nose安装完成后,确实能用了。

这里看貌似也并没有安装atlas和lapack,不知道是不是系统自带了的缘故,并且apt-get install的方式不会出现安装numpy时找不到gfortran的错误,可以说是“一键”解决,这里mark下。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  ubuntu 集群