安装GPU版本的LightGBM的的正确姿势

【 安装GPU版本的LightGBM的的正确姿势 】

1.install something:

sudo apt-get install libboost-all-dev  
sudo apt install ocl-icd-opencl-dev
sudo apt install cmake

2. update pip

pip3 install --upgrade pip

2.pip install lightgbm

pip3 install lightgbm --install-option=--gpu

安装完成,enjoy~

 

 

【 DEBUG过程 】

使用lightgbm时报错如下:
 

LightGBMError: GPU Tree Learner was not enabled in this build.
Please recompile with CMake option -DUSE_GPU=1

分析原因:

安装lightgbm模型时未指定gpu选项。

解决方法:

重新安装gpu版lightgbm。

 

卸载原lightgbm:

pip3 uninstall lightgbm

 

ubuntu18.04下,直接使用pip安装:

pip install lightgbm --install-option=--gpu

但是,报错了,报错如下:

Skipping bdist_wheel for lightgbm, due to binaries being disabled for it.
Skipping bdist_wheel for numpy, due to binaries being disabled for it.
Skipping bdist_wheel for scipy, due to binaries being disabled for it.
Skipping bdist_wheel for scikit-learn, due to binaries being disabled for it.
Skipping bdist_wheel for joblib, due to binaries being disabled for it.
Skipping bdist_wheel for threadpoolctl, due to binaries being disabled for it.
Installing collected packages: numpy, scipy, joblib, threadpoolctl, scikit-learn, lightgbm
  Running setup.py install for numpy ... error
    Complete output from command /usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-_vdjco2f/numpy/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-hxzyd19i-record/install-record.txt --single-version-externally-managed --compile --gpu --opencl-include-dir=/usr/local/cuda/include/ --opencl-library=/usr/local/cuda/lib64/libOpenCL.so --user --prefix=:
    Running from numpy source directory.

    Note: if you need reliable uninstall behavior, then install
    with pip instead of using `setup.py install`:

      - `pip install .`       (from a git repo or downloaded source
                               release)
      - `pip install numpy`   (last NumPy release on PyPi)


    Cythonizing sources
    Processing numpy/random/_bounded_integers.pxd.in
    Processing numpy/random/_common.pyx
    Processing numpy/random/_bounded_integers.pyx.in
    Processing numpy/random/_sfc64.pyx
    Processing numpy/random/_mt19937.pyx
    Processing numpy/random/mtrand.pyx
    Processing numpy/random/_pcg64.pyx
    Processing numpy/random/_philox.pyx
    Processing numpy/random/_generator.pyx
    Processing numpy/random/_bit_generator.pyx
    usage: -c [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
       or: -c --help [cmd1 cmd2 ...]
       or: -c --help-commands
       or: -c cmd --help

    error: option --gpu not recognized

    ----------------------------------------
Command "/usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-_vdjco2f/numpy/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-hxzyd19i-record/install-record.txt --single-version-externally-managed --compile --gpu --opencl-include-dir=/usr/local/cuda/include/ --opencl-library=/usr/local/cuda/lib64/libOpenCL.so --user --prefix=" failed with error code 1 in /tmp/pip-build-_vdjco2f/numpy/

 

于是,选择 git clone代码后安装:

1.install boost:

sudo apt-get install libboost-all-dev  

2.Clone LightGBM and build with CUDA enabled

git clone --recursive https://github.com/Microsoft/LightGBM && cd LightGBM  
export CXX=g++-7 CC=gcc-7  # replace 7 with version of gcc installed on your machine  
mkdir build && cd build  
cmake .. -DUSE_GPU=1  
make -j4  

但是,在`cmake .. -DUSE_GPU=1 `这一步报错了:

  Could NOT find OpenCL (missing: OpenCL_LIBRARY OpenCL_INCLUDE_DIR)
Call Stack (most recent call first):
  /usr/share/cmake-3.10/Modules/FindPackageHandleStandardArgs.cmake:378 (_FPHSA_FAILURE_MESSAGE)
  /usr/share/cmake-3.10/Modules/FindOpenCL.cmake:132 (find_package_handle_standard_args)
  CMakeLists.txt:115 (find_package)


-- Configuring incomplete, errors occurred!
See also "/home/hxy/LightGBM/build/CMakeFiles/CMakeOutput.log".
See also "/home/hxy/LightGBM/build/CMakeFiles/CMakeError.log".

查阅资料,安装 以下即可:

sudo apt install ocl-icd-opencl-dev

 

Reference:

1.https://lightgbm.readthedocs.io/en/latest/Installation-Guide.html

2.http://blog.manugarri.com/note-to-self-installing-lightgbm-in-ubuntu-18-04/

3.https://github.com/fireice-uk/xmr-stak-amd/issues/97

  • 3
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值