日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

lightGBM GPU支持的安装、验证方法

發布時間:2023/12/15 编程问答 26 豆豆
生活随笔 收集整理的這篇文章主要介紹了 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-dev

2、安裝python庫

pip install setuptools wheel numpy scipy scikit-learn -U

3、安裝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 install

4、測試

編寫測試腳本

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支持的安装、验证方法的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。