Monday, June 19, 2017

Error with Python import LightGBM

Leave a Comment

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?

1 Answers

Answers 1

To use LGBM in python you need to install a python wrapper for CLI. Maybe something like this. Then you need to point this wrapper to the CLI. You could look up GBMClassifier/ Regressor where there is a variable called exec_path. You should set up the absolute path here.

Hopefully this helps , I will take an example of this wrapper Here is the example : `

import numpy as np from sklearn import datasets, metrics, model_selection from pylightgbm.models import GBMClassifier exec = "~/Documents/apps/LightGBM/lightgbm" X, Y = datasets.make_classification(n_samples=200, n_features=10) x_train, x_test, y_train, y_test = model_selection.train_test_split(X, Y, test_size=0.2) clf = GBMClassifier(exec_path=exec, min_data_in_leaf=1) clf.fit(x_train, y_train, test_data=[(x_test, y_test)]) y_pred = clf.predict(x_test) print("Accuracy: ", metrics.accuracy_score(y_test, y_pred)) 

`

If You Enjoyed This, Take 5 Seconds To Share It

0 comments:

Post a Comment