Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[jvm-packages] [pyspark] Make cuDF optional in PySpark package #8469

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions python-package/xgboost/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ def lazy_isinstance(instance: Any, module: str, name: str) -> bool:
pandas_concat = None
PANDAS_INSTALLED = False


# cuDF
CUDF_INSTALLED = importlib.util.find_spec("cudf") is not None


# sklearn
try:
from sklearn.base import BaseEstimator as XGBModelBase
Expand Down
4 changes: 2 additions & 2 deletions python-package/xgboost/spark/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import numpy as np
import pandas as pd
from scipy.sparse import csr_matrix
from xgboost.compat import concat
from xgboost.compat import CUDF_INSTALLED, concat

from xgboost import DataIter, DMatrix, QuantileDMatrix

Expand Down Expand Up @@ -81,7 +81,7 @@ def _fetch(self, data: Optional[Sequence[pd.DataFrame]]) -> Optional[pd.DataFram
if not data:
return None

if self._device_id is not None:
if self._device_id is not None and CUDF_INSTALLED:
import cudf # pylint: disable=import-error
import cupy as cp # pylint: disable=import-error

Expand Down