LightGBMError:b'No OpenCL设备发现'

时间:2018-05-31 15:34:09

标签: python gpu google-colaboratory lightgbm

我想使用Google colaboratory在我的数据集上使用GPU训练LightGBM(我还选择运行时Python3和GPU)。为此,我使用了以下代码块:

use Weew\Timer\Timer; // same as "use Weew\Timer\Timer as Timer;"
$timer = new Timer;

同样在笔记本中我选择了设备gpu:

!apt-get -qq install --no-install-recommends nvidia-375
!apt-get -qq install --no-install-recommends nvidia-opencl-icd-375 nvidia-opencl-dev opencl-headers
#!apt-get update
!apt-get install --no-install-recommends git cmake build-essential libboost-dev libboost-system-dev libboost-filesystem-dev ocl-icd-libopencl1 ocl-icd-opencl-dev
!pip install -qq lightgbm --install-option=--gpu 

得到了这个:

clf = LGBMClassifier(
        n_estimators=10000,
        learning_rate=0.03,
        num_leaves=30,
        colsample_bytree=.8,
        subsample=.9,
        max_depth=7,
        reg_alpha=.1,
        reg_lambda=.1,
        min_split_gain=.01,
        min_child_weight=2,
        silent=-1,
        verbose=-1,
        device = 'gpu'
        #gpu_platform_id: '0'
        #gpu_device_id: '0'
        )

我也试过这个解决方案Installing GPU support for LightGBM on Google Collab,但没有改变

1 个答案:

答案 0 :(得分:0)

我遵循了https://github.com/microsoft/LightGBM/issues/586的建议,但是并没有解决我的问题。事实证明,LightGBM库无法识别到libnvidia-opencl.so的路径。因此,我将libnvidia-opencl.so.1的路径修改为/usr/lib/x86_64-linux-gnu/libnvidia-opencl.so.1。然后它起作用了。

单行解决方案是:

mkdir -p /etc/OpenCL/vendors && \ echo "/usr/lib/x86_64-linux-gnu/libnvidia-opencl.so.1" > /etc/OpenCL/vendors/nvidia.icd

当然,您必须确保正确安装了Nvidia驱动程序。对于Ubuntu 18.04,您可以按照以下说明https://www.linuxbabe.com/ubuntu/install-nvidia-driver-ubuntu-18-04