Fix gpu_id with custom objective. (#7015)

This commit is contained in:
Jiaming Yuan
2021-06-09 14:51:17 +08:00
committed by GitHub
parent bd2ca543c4
commit 72f9daf9b6
3 changed files with 19 additions and 6 deletions

View File

@@ -6,11 +6,13 @@ import pytest
sys.path.append("tests/python")
# Don't import the test class, otherwise they will run twice.
import test_callback as test_cb # noqa
import test_basic_models as test_bm
rng = np.random.RandomState(1994)
class TestGPUBasicModels:
cputest = test_cb.TestCallbacks()
cpu_test_cb = test_cb.TestCallbacks()
cpu_test_bm = test_bm.TestModels()
def run_cls(self, X, y, deterministic):
cls = xgb.XGBClassifier(tree_method='gpu_hist',
@@ -35,9 +37,12 @@ class TestGPUBasicModels:
return hash(model_0), hash(model_1)
def test_custom_objective(self):
self.cpu_test_bm.run_custom_objective("gpu_hist")
def test_eta_decay_gpu_hist(self):
self.cputest.run_eta_decay('gpu_hist', True)
self.cputest.run_eta_decay('gpu_hist', False)
self.cpu_test_cb.run_eta_decay('gpu_hist', True)
self.cpu_test_cb.run_eta_decay('gpu_hist', False)
def test_deterministic_gpu_hist(self):
kRows = 1000