lightGBM GPU支持的安装、验证方法
程序员文章站
2024-02-26 17:06:10
...
以下基于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-dev
2、安装python库
pip install setuptools wheel numpy scipy scikit-learn -U
3、安装lightGBM-GPU
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"
4、测试
编写测试脚本
import lightgbm as lgb
import time
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': '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
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
上一篇: Java与Http协议的详细介绍
推荐阅读
-
lightGBM GPU支持的安装、验证方法
-
在Python安装MySQL支持模块的方法
-
在Python安装MySQL支持模块的方法
-
在Macbook Pro上安装支持GPU的TensorFlow
-
您的服务器不支持MySql数据库,无法安装论坛程序的解决方法
-
安装oracle11g INS-30131执行安装程序验证所需的初始设置失败的解决方法
-
win2003安装sqlserver 2000提示无法验证产品密钥的解决方法
-
win2003安装sqlserver 2000提示无法验证产品密钥的解决方法
-
hadoop入门之通过页面验证hadoop是否安装成功的方法
-
Win7使用金山毒霸提示“安装引擎失败,不支持此接口”的解决方法