Remove MGPU cpp tests. (#8276)
Co-authored-by: Hyunsu Philip Cho <chohyu01@cs.washington.edu>
This commit is contained in:
@@ -148,10 +148,9 @@ class TestGPUPredict:
|
||||
from_dmatrix = booster.predict(dtrain)
|
||||
cp.testing.assert_allclose(from_inplace, from_dmatrix)
|
||||
|
||||
@pytest.mark.skipif(**tm.no_cupy())
|
||||
def test_inplace_predict_cupy(self):
|
||||
def run_inplace_predict_cupy(self, device: int) -> None:
|
||||
import cupy as cp
|
||||
cp.cuda.runtime.setDevice(0)
|
||||
cp.cuda.runtime.setDevice(device)
|
||||
rows = 1000
|
||||
cols = 10
|
||||
missing = 11 # set to integer for testing
|
||||
@@ -166,15 +165,17 @@ class TestGPUPredict:
|
||||
|
||||
dtrain = xgb.DMatrix(X, y)
|
||||
|
||||
booster = xgb.train({'tree_method': 'gpu_hist'}, dtrain, num_boost_round=10)
|
||||
booster = xgb.train(
|
||||
{'tree_method': 'gpu_hist', "gpu_id": device}, dtrain, num_boost_round=10
|
||||
)
|
||||
|
||||
test = xgb.DMatrix(X[:10, ...], missing=missing)
|
||||
predt_from_array = booster.inplace_predict(X[:10, ...], missing=missing)
|
||||
predt_from_dmatrix = booster.predict(test)
|
||||
|
||||
cp.testing.assert_allclose(predt_from_array, predt_from_dmatrix)
|
||||
|
||||
def predict_dense(x):
|
||||
cp.cuda.runtime.setDevice(device)
|
||||
inplace_predt = booster.inplace_predict(x)
|
||||
d = xgb.DMatrix(x)
|
||||
copied_predt = cp.array(booster.predict(d))
|
||||
@@ -183,7 +184,8 @@ class TestGPUPredict:
|
||||
# Don't do this on Windows, see issue #5793
|
||||
if sys.platform.startswith("win"):
|
||||
pytest.skip(
|
||||
'Multi-threaded in-place prediction with cuPy is not working on Windows')
|
||||
'Multi-threaded in-place prediction with cuPy is not working on Windows'
|
||||
)
|
||||
for i in range(10):
|
||||
run_threaded_predict(X, rows, predict_dense)
|
||||
|
||||
@@ -196,13 +198,28 @@ class TestGPUPredict:
|
||||
|
||||
missing_idx = [i for i in range(0, X.shape[1], 16)]
|
||||
X[:, missing_idx] = missing
|
||||
reg = xgb.XGBRegressor(tree_method="gpu_hist", n_estimators=8, missing=missing)
|
||||
reg = xgb.XGBRegressor(
|
||||
tree_method="gpu_hist", n_estimators=8, missing=missing, gpu_id=device
|
||||
)
|
||||
reg.fit(X, y)
|
||||
|
||||
gpu_predt = reg.predict(X)
|
||||
reg.set_params(predictor="cpu_predictor")
|
||||
cpu_predt = reg.predict(X)
|
||||
np.testing.assert_allclose(gpu_predt, cpu_predt, atol=1e-6)
|
||||
cp.cuda.runtime.setDevice(0)
|
||||
|
||||
@pytest.mark.skipif(**tm.no_cupy())
|
||||
def test_inplace_predict_cupy(self):
|
||||
self.run_inplace_predict_cupy(0)
|
||||
|
||||
@pytest.mark.skipif(**tm.no_cupy())
|
||||
@pytest.mark.mgpu
|
||||
def test_inplace_predict_cupy_specified_device(self):
|
||||
import cupy as cp
|
||||
n_devices = cp.cuda.runtime.getDeviceCount()
|
||||
for d in range(n_devices):
|
||||
self.run_inplace_predict_cupy(d)
|
||||
|
||||
@pytest.mark.skipif(**tm.no_cupy())
|
||||
@pytest.mark.skipif(**tm.no_cudf())
|
||||
|
||||
Reference in New Issue
Block a user