python lightgbm gpu版本,启动!

  • 环境
    • Ubuntu 20.04.2
    • Python 3.8.10
    • Nvidia-smi driver 535.104.05
    • cuda 12.2
    • torch 1.13.1+cu116(torch cuda 11.6)
  • 步骤
    • 注:因为先尝试了pip3 install lightgbm, 安装了没有gpu兼容性的3.1.1版本, 所以下面安装时使用了--upgrade选项
    • >  python3 -m pip install --upgrade pip
      ...
      Installing collected packages: pip
      Successfully installed pip-24.2
      >  pip3 install lightgbm --upgrade
      Defaulting to user installation because normal site-packages is not writeable
      Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
      Requirement already satisfied: lightgbm in /usr/local/lib/python3.8/dist-packages (3.1.1)
      Collecting lightgbm
      Downloading https://pypi.tuna.tsinghua.edu.cn/packages/4e/19/1b928cad70a4e1a3e2c37d5417ca2182510f2451eaadb6c91cd9ec692cae/lightgbm-4.5.0-py3-none-manylinux_2_28_x86_64.whl (3.6 MB)
      ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 3.6/3.6 MB 20.2 MB/s eta 0:00:00
      Requirement already satisfied: numpy>=1.17.0 in /usr/local/lib/python3.8/dist-packages (from lightgbm) (1.19.5)
      Requirement already satisfied: scipy in /usr/local/lib/python3.8/dist-packages (from lightgbm) (1.10.1)
      Installing collected packages: lightgbm
      Successfully installed lightgbm-4.5.0
  •  测试
    • >  python3
      Python 3.8.10 (default, Jul 29 2024, 17:02:10) 
      [GCC 9.4.0] on linux
      Type "help", "copyright", "credits" or "license" for more information.
      >>> import lightgbm as lgb
      >>> import numpy as np
      >>> a1 = np.random.random((10,3))
      >>> a2 = np.random.random(10)
      >>> para = {'device_type': 'gpu'}
      >>> model = lgb.train(para,train_set=lgb.Dataset(a1,a2))
      [LightGBM] [Warning] There are no meaningful features which satisfy the provided configuration. Decreasing Dataset parameters min_data_in_bin or min_data_in_leaf and re-constructing Dataset might resolve this warning.
      [LightGBM] [Info] This is the GPU trainer!!
      [LightGBM] [Info] Total Bins 0
      [LightGBM] [Info] Number of data points in the train set: 10, number of used features: 0
      [LightGBM] [Info] Using GPU Device: NVIDIA H100 PCIe, Vendor: NVIDIA Corporation
      [LightGBM] [Info] Compiling OpenCL Kernel with 16 bins...
      1 warning generated.
      1 warning generated.
      ... ...
      1 warning generated.
      1 warning generated.
      [LightGBM] [Info] GPU programs have been built
      [LightGBM] [Warning] GPU acceleration is disabled because no non-trivial dense features can be found
      [LightGBM] [Info] Start training from score 0.482093
      [LightGBM] [Warning] Stopped training because there are no more leaves that meet the split requirements
      [LightGBM] [Warning] Stopped training because there are no more leaves that meet the split requirements
      ... ...
      [LightGBM] [Warning] Stopped training because there are no more leaves that meet the split requirements
      ... ...

       

posted on 2024-08-21 14:40  Mju_halcyon  阅读(67)  评论(0编辑  收藏  举报

导航