Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error with Python import LightGBM

Tags:

python

opencv

I have installed lightGBM as described here on Linux:

https://github.com/Microsoft/LightGBM/wiki/Installation-Guide#linux-2

I am able to successfully run the GPU training (and CPU) using the CLI: https://github.com/Microsoft/LightGBM/blob/master/docs/GPU-Tutorial.md#run-your-first-learning-task-on-gpu

However, when i try to import the python package (python 3.6) I receive the following error:

OSError: /home/anaconda3/lib/python3.6/site-packages/lightgbm-0.2-py3.6.egg/lightgbm/lib_lightgbm.so: symbol clCreateCommandQueueWithProperties, version OPENCL_2.0 not defined in file libOpenCL.so.1 with link time reference

I am pretty new to understanding linking and other things that may be the problem. Anyone able to provide some easy to follow suggestions?

like image 502
B_Miner Avatar asked May 21 '17 14:05

B_Miner


People also ask

How do I use LGBM in Python?

Coding an LGBM in Python The LGBM model can be installed by using the Python pip function and the command is “pip install lightbgm” LGBM also has a custom API support in it and using it we can implement both Classifier and regression algorithms where both the models operate in a similar fashion.


1 Answers

LightGBM now comes with a python API.

import numpy as np
from lightgbm import LGBMClassifier
from sklearn.datasets import make_moons


model = LGBMClassifier(boosting_type='goss', num_leaves=31, max_depth=- 1, learning_rate=0.1, n_estimators=300, device = "gpu")

train, label = make_moons(n_samples=300000, shuffle=True, noise=0.3, random_state=None)

model.fit(train, label)

If you managed to build it for the GPU, you are probably a couple of steps away from setting up the python interface.

Assuming the built was successful and the repertory looks like this:

~/Codes/LightGBM$ tree -d -L 1
.
├── build
├── compute
├── docker
├── docs
├── examples
├── helpers
├── include
├── pmml
├── python-package
├── R-package
├── src
├── swig
├── tests
└── windows

Simply use the following commands to set up the python API.

cd python-package/
sudo python setup.py install --precompile

Source detailed guide to install LightGBM with GPU support

like image 103
RUser4512 Avatar answered Oct 09 '22 22:10

RUser4512