lightGBM GPU支持的安装、验证方法
生活随笔
收集整理的這篇文章主要介紹了
lightGBM GPU支持的安装、验证方法
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
以下基于ubuntu 16.04 python 3.6.5安裝測試成功
1、安裝軟件依賴
sudo apt-get install --no-install-recommends git cmake build-essential libboost-dev libboost-system-dev libboost-filesystem-dev2、安裝python庫
pip install setuptools wheel numpy scipy scikit-learn -U3、安裝lightGBM-GPU
3.1 pip安裝
sudo pip3 install lightgbm --install-option=--gpu --install-option="--opencl-include-dir=/usr/local/cuda/include/" --install-option="--opencl-library=/usr/local/cuda/lib64/libOpenCL.so"3.1 源碼安裝
git clone --recursive https://github.com/microsoft/LightGBM ; cd LightGBM mkdir build ; cd build cmake -DUSE_GPU=1 .. # if you have installed NVIDIA CUDA to a customized location, you should specify paths to OpenCL headers and library like the following: # cmake -DUSE_GPU=1 -DOpenCL_LIBRARY=/usr/local/cuda/lib64/libOpenCL.so -DOpenCL_INCLUDE_DIR=/usr/local/cuda/include/ .. make -j$(nproc)?
cd ../python-package/ python setup.py install4、測試
編寫測試腳本
import lightgbm as lgb import timeparams = {'max_bin': 63, 'num_leaves': 255, 'learning_rate': 0.1, 'tree_learner': 'serial', 'task': 'train', 'is_training_metric': 'false', 'min_data_in_leaf': 1, 'min_sum_hessian_in_leaf': 100, 'ndcg_eval_at': [1,3,5,10], 'sparse_threshold': 1.0, 'nthread': 1, 'device': 'gpu', 'gpu_platform_id': 0, 'gpu_device_id': 0}dtrain = lgb.Dataset('train.libsvm') t0 = time.time() gbm = lgb.train(params, train_set=dtrain, num_boost_round=100,valid_sets=None, valid_names=None,fobj=None, feval=None, init_model=None,feature_name='auto', categorical_feature='auto',early_stopping_rounds=None, evals_result=None,verbose_eval=True,keep_training_booster=False, callbacks=None) t1 = time.time()print('gpu version elapse time: {}'.format(t1-t0))params = {'max_bin': 63, 'num_leaves': 255, 'learning_rate': 0.1, 'tree_learner': 'serial', 'task': 'train', 'is_training_metric': 'false', 'min_data_in_leaf': 1, 'min_sum_hessian_in_leaf': 100, 'ndcg_eval_at': [1,3,5,10], 'sparse_threshold': 1.0, 'nthread': 1, 'device': 'cpu' }t0 = time.time() gbm = lgb.train(params, train_set=dtrain, num_boost_round=100,valid_sets=None, valid_names=None,fobj=None, feval=None, init_model=None,feature_name='auto', categorical_feature='auto',early_stopping_rounds=None, evals_result=None,verbose_eval=True,keep_training_booster=False, callbacks=None) t1 = time.time()print('cpu version elapse time: {}'.format(t1-t0))?
CPU 32s? vs? CPU 8s
5、遇到問題
?
5.1? terminate called without an active exception
源文件目錄:src/treelearner/gpu_tree_learner.h的第26行代碼:
#define BOOST_COMPUTE_USE_OFFLINE_CACHE
如果包含這個這個宏 BOOST_COMPUTE_USE_OFFLINE_CACHE,就會導致要尋找緩存目錄,因此將其注釋,并clean然后重新編譯源文件,然后就能安裝使用了。
?
5.2 Error: No OpenCL Device Found
mkdir -p /etc/OpenCL/vendors && echo "libnvidia-opencl.so.1" > /etc/OpenCL/vendors/nvidia.icd
?
參考:https://www.kaggle.com/kirankunapuli/ieee-fraud-lightgbm-with-gpu
總結
以上是生活随笔為你收集整理的lightGBM GPU支持的安装、验证方法的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 工行转账每天最大额度,分以下五点
- 下一篇: [kubernetes] 证书详细总结