From e8caefa8874ad1e5f719ec255f44b2756db0f025 Mon Sep 17 00:00:00 2001 From: Benjamin Zaitlen Date: Mon, 17 Oct 2022 11:40:11 -0700 Subject: [PATCH 1/3] small fixes for cupy11 --- python-package/xgboost/dask.py | 2 +- python-package/xgboost/data.py | 1 - tests/python-gpu/test_from_cupy.py | 1 + 3 files changed, 2 insertions(+), 2 deletions(-) diff --git a/python-package/xgboost/dask.py b/python-package/xgboost/dask.py index c6a0d96c5e80..5b23aaceab35 100644 --- a/python-package/xgboost/dask.py +++ b/python-package/xgboost/dask.py @@ -272,7 +272,7 @@ def concat(value: Any) -> Any: # pylint: disable=too-many-return-statements from cudf import concat as CUDF_concat # pylint: disable=import-error return CUDF_concat(value, axis=0) - if lazy_isinstance(value[0], "cupy._core.core", "ndarray"): + if lazy_isinstance(value[0], "cupy", "ndarray"): import cupy # pylint: disable=c-extension-no-member,no-member diff --git a/python-package/xgboost/data.py b/python-package/xgboost/data.py index 219737e036c5..a9af782db1c0 100644 --- a/python-package/xgboost/data.py +++ b/python-package/xgboost/data.py @@ -712,7 +712,6 @@ def _is_cupy_array(data) -> bool: for n in ("cupy.core.core", "cupy", "cupy._core.core") ) - def _transform_cupy_array(data): import cupy # pylint: disable=import-error if not hasattr(data, '__cuda_array_interface__') and hasattr( diff --git a/tests/python-gpu/test_from_cupy.py b/tests/python-gpu/test_from_cupy.py index 77fa694e58fa..84ec0cd1eb87 100644 --- a/tests/python-gpu/test_from_cupy.py +++ b/tests/python-gpu/test_from_cupy.py @@ -220,4 +220,5 @@ def test_specified_device(self): np.float32, xgb.DeviceQuantileDMatrix, np.nan) with pytest.raises(xgb.core.XGBoostError): xgb.train({'tree_method': 'gpu_hist', 'gpu_id': 1}, + 'fail_on_invalid_gpu_id': True}, dtrain, num_boost_round=10) From df44f351859ff7eee3326884ae4b9ffd23fce75f Mon Sep 17 00:00:00 2001 From: Benjamin Zaitlen Date: Tue, 18 Oct 2022 11:18:17 -0400 Subject: [PATCH 2/3] Update python-package/xgboost/dask.py Co-authored-by: Jiaming Yuan --- python-package/xgboost/dask.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/python-package/xgboost/dask.py b/python-package/xgboost/dask.py index 5b23aaceab35..6fa26b657d81 100644 --- a/python-package/xgboost/dask.py +++ b/python-package/xgboost/dask.py @@ -272,7 +272,9 @@ def concat(value: Any) -> Any: # pylint: disable=too-many-return-statements from cudf import concat as CUDF_concat # pylint: disable=import-error return CUDF_concat(value, axis=0) - if lazy_isinstance(value[0], "cupy", "ndarray"): + from .data import _is_cupy_array + + if _is_cupy_array(value[0]): import cupy # pylint: disable=c-extension-no-member,no-member From 3ec1e5eb5fad64e8b252f1dc9942bfc48278bd9e Mon Sep 17 00:00:00 2001 From: Benjamin Zaitlen Date: Tue, 18 Oct 2022 11:19:12 -0400 Subject: [PATCH 3/3] Update test_from_cupy.py remove unnecessary option --- tests/python-gpu/test_from_cupy.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/python-gpu/test_from_cupy.py b/tests/python-gpu/test_from_cupy.py index 84ec0cd1eb87..77fa694e58fa 100644 --- a/tests/python-gpu/test_from_cupy.py +++ b/tests/python-gpu/test_from_cupy.py @@ -220,5 +220,4 @@ def test_specified_device(self): np.float32, xgb.DeviceQuantileDMatrix, np.nan) with pytest.raises(xgb.core.XGBoostError): xgb.train({'tree_method': 'gpu_hist', 'gpu_id': 1}, - 'fail_on_invalid_gpu_id': True}, dtrain, num_boost_round=10)