赞
踩
这里文档的安装指南是CLI版本,不需要。具体安装link进这个:
install:
Exception: Please install CMake and all required dependencies first
有三条依赖环境:
For Windows users, CMake (version 3.8 or higher) is strongly required.
Boost and OpenCL are needed:...
安装lib过程
#下列【新】软件包将被安装:
# nvidia-opencl-dev ocl-icd-opencl-dev
sudo apt install nvidia-opencl-dev
sudo apt install ocl-icd-libopencl1 ocl-icd-opencl-dev
sudo apt install libboost-dev libboost-system-dev libboost-filesystem-dev
# in conda env
conda install cmake
install
pip install lightgbm --install-option=--gpu
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
# 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': 'gpu',
# 'gpu_platform_id': 0,
# 'gpu_device_id': 0}
#
dtrain = lgb.Dataset(data=np.array([[2, 23, 34, 54, 1], [21, 23, 4, 64, 1], [27, 53, 3, 4, 0]]))
# 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('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,
'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))
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语言写的
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。