lightgbm_gpu install
github
doc
这里文档的安装指南是CLI版本,不需要。具体安装link进这个:
python-package
概述
安装
install:
gpu test:
https://github.com/microsoft/LightGBM/issues/3939
测试代码一:
import lightgbm
import numpy as np
def check_gpu_support():
data = np.random.rand(50, 2)
label = np.random.randint(2, size=50)
print(label)
train_data = lightgbm.Dataset(data, label=label)
params = {'num_iterations': 1, 'device': 'gpu'}
try:
gbm = lightgbm.train(params, train_set=train_data)
print("GPU True !!!")
except Exception as e:
print("GPU False !!!")
if __name__ == '__main__':
check_gpu_support()
测试代码二:
import lightgbm as lgb
import time
import numpy as np
dtrain = lgb.Dataset(data=np.array([[2, 23, 34, 54, 1], [21, 23, 4, 64, 1], [27, 53, 3, 4, 0]]))
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,
'device': 'cpu'
}
t0 = time.time()
gbm = lgb.train(params, train_set=dtrain, num_boost_round=10,
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))
关于gpu版本和cuda版本
github-issue_gpu文档不清楚
cuda版本:使用device_type="cuda" 代替device_type="gpu"
最新回答:
CUDA version is a re-written in CUDA language GPU version for systems where OpenCL is not available.
总结:
gpu版本:我用的python的版本,所以是python语言
cuda版本:用的cuda语言写的
|