Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
Signed-off-by: Weichen Xu <weichen.xu@databricks.com>
  • Loading branch information
WeichenXu123 committed Nov 24, 2022
1 parent 62d1848 commit 943921c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
10 changes: 5 additions & 5 deletions python-package/xgboost/compat.py
Expand Up @@ -76,13 +76,13 @@ def lazy_isinstance(instance: Any, module: str, name: str) -> bool:
_logger = logging.getLogger(__name__)


def is_cudf_installed() -> bool:
"""Check cuDF installed or not"""
# Checking by `importing` instead of check `importlib.util.find_spec("cudf") is not None`
# because user might install cudf successfully but importing cudf raises issues (e.g. saying
# running on mismatched cuda version)
def is_cudf_available() -> bool:
"""Check cuDF package available or not"""
if importlib.util.find_spec("cudf") is None:
return False
try:
import cudf

return True
except ImportError:
_logger.exception("Importing cuDF failed, use DMatrix instead of QDM")
Expand Down
6 changes: 3 additions & 3 deletions python-package/xgboost/spark/core.py
Expand Up @@ -32,12 +32,12 @@
ShortType,
)
from scipy.special import expit, softmax # pylint: disable=no-name-in-module
from xgboost.compat import is_cudf_available
from xgboost.core import Booster
from xgboost.training import train as worker_train

import xgboost
from xgboost import XGBClassifier, XGBRanker, XGBRegressor
from xgboost.compat import is_cudf_installed

from .data import (
_read_csr_matrix_from_unwrapped_spark_vec,
Expand Down Expand Up @@ -773,10 +773,10 @@ def _train_booster(pandas_df_iter):

# If cuDF is not installed, then using DMatrix instead of QDM,
# because without cuDF, DMatrix performs better than QDM.
# Note: Checking `is_cudf_installed` in spark worker side because
# Note: Checking `is_cudf_available` in spark worker side because
# spark worker might has different python environment with driver side.
if use_gpu:
use_qdm = use_hist and is_cudf_installed()
use_qdm = use_hist and is_cudf_available()
else:
use_qdm = use_hist

Expand Down

0 comments on commit 943921c

Please sign in to comment.