Skip to content
This repository has been archived by the owner on Nov 14, 2023. It is now read-only.

[Bug] GPU not utilized #59

Closed
rohan-gt opened this issue Jul 24, 2020 · 1 comment · Fixed by #60
Closed

[Bug] GPU not utilized #59

rohan-gt opened this issue Jul 24, 2020 · 1 comment · Fixed by #60

Comments

@rohan-gt
Copy link

rohan-gt commented Jul 24, 2020

Tried running the following code on a Colab with the GPU enabled but I get a message saying Warning: you are connected to a GPU runtime, but not utilizing the GPU.

# Install and import libraries
!pip install -U lightgbm
!pip install -U 'ray[tune]'
!pip install -U scikit-optimize
!pip install -U tune_sklearn

from lightgbm import LGBMClassifier
import pandas as pd
import ray
from sklearn.datasets import load_breast_cancer
from sklearn.model_selection import train_test_split
from tune_sklearn import TuneSearchCV

# Load data
cancer = load_breast_cancer()
X = cancer.data
y = cancer.target

# Train-test split
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)

# Tune
model = LGBMClassifier()
param_dists = {
    'boosting_type': ['gbdt'],
    'colsample_bytree': (0.8, 0.9, 'log-uniform'),
    'reg_alpha': (1.1, 1.3),
    'reg_lambda': (1.1, 1.3),
    'min_split_gain': (0.3, 0.4),
    'subsample': (0.7, 0.9),
    'subsample_freq': (20, 21)
}

tuner = TuneSearchCV(
    model,
    param_dists,
    n_iter=20,
    scoring='f1_weighted',
    n_jobs=-1,
    verbose=2,
    max_iters=10,
    search_optimization='bayesian',
    use_gpu=True,
)

tuner.fit(X_train, y_train)
print('Best Parameters :', tuner.best_params_)
@inventormc
Copy link
Collaborator

Hey @rohan-gt thanks for reaching out. This is a bug on our part; I'll let you know when our fix is pushed. The GPU support should work for grid search though.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants