zoukankan      html  css  js  c++  java
  • lightgbm GPU版本安装

     python机器学习-乳腺癌细胞挖掘(博主亲自录制视频)https://study.163.com/course/introduction.htm?courseId=1005269003&utm_campaign=commission&utm_source=cp-400000000398149&utm_medium=share

     

    官网

    https://lightgbm.readthedocs.io/en/latest/GPU-Windows.html

    lightgbm GPU版本 Windows情况下安装:

    https://www.jianshu.com/p/30555fd2bd50

    以下基于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.6 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、测试

    先下载测试文件并且进行文件转化

    git clone https://github.com/guolinke/boosting_tree_benchmarks.git
    cd boosting_tree_benchmarks/data
    wget "https://archive.ics.uci.edu/ml/machine-learning-databases/00280/HIGGS.csv.gz"
    gunzip HIGGS.csv.gz
    python higgs2libsvm.py
    编写测试脚本

    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,
    'device': 'gpu',
    'gpu_platform_id': 0,
    'gpu_device_id': 0}


    dtrain = lgb.Dataset('data/higgs.train')
    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))
    测试结果如下,可见gpu版确实比cpu快

     https://study.163.com/provider/400000000398149/index.htm?share=2&shareId=400000000398149( 欢迎关注博主主页,学习python视频资源,还有大量免费python经典文章)


  • 相关阅读:
    HDU 1003——Max Sum(动态规划)
    HDU 2602 ——背包问题
    HDU 1850——Being a good boy
    HDU——2588 数论应用
    HDU1222——数论
    HDU1465——不容易系列之一(错排)
    URAL 2038 Minimum Vertex Cover
    772002画马尾
    CodeForces 19D Points
    The 2015 China Collegiate Programming Contest Game Rooms
  • 原文地址:https://www.cnblogs.com/webRobot/p/10941891.html
Copyright © 2011-2022 走看看