Skip to content

Commit

Permalink
Fix GPU warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomasMeissnerDS committed Aug 18, 2024
1 parent bfcecfc commit aaa6fb7
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions bluecast/general_utils/general_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def check_gpu_support() -> Dict[str, str]:
d_train = xgb.DMatrix(data, label=label)

params_list = [
{"device": "cuda", "tree_method": "gpu_hist"},
{"tree_method": "gpu_hist"},
]

for params in params_list:
Expand Down Expand Up @@ -67,7 +67,7 @@ def check_gpu_support() -> Dict[str, str]:
logger.warning("Failed with params %s. Error: %s", params, str(e))

# If no GPU parameters work, fall back to CPU
params = {"tree_method": "hist", "device": "cpu"}
params = {"tree_method": "hist"}
logger.info("No GPU detected. Xgboost will use CPU with parameters: %s", params)
return params

Expand Down
6 changes: 3 additions & 3 deletions bluecast/ml_modelling/parameter_tuning_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ def update_params_based_on_tree_method(
param["tree_method"] = trial.suggest_categorical(
"tree_method", xgboost_params.tree_method
)
if param["tree_method"] in ["hist", "approx"]:
if param["tree_method"] in ["hist", "approx", "gpu_hist"]:
param["max_bin"] = trial.suggest_int(
"max_bin", xgboost_params.max_bin_min, xgboost_params.max_bin_max
)

if param.get("device", "cpu") == "cpu":
if param.get("device", None) == "cpu":
del param["device"]

param["booster"] = trial.suggest_categorical("booster", xgboost_params.booster)
Expand Down Expand Up @@ -58,7 +58,7 @@ def get_params_based_on_device(
"""Get parameters based on available or chosen device."""
if conf_training.autotune_on_device in ["auto"]:
train_on = check_gpu_support()
conf_params_xgboost.params["device"] = train_on["device"]
conf_params_xgboost.params["device"] = train_on.get("device", None)
if "exact" in conf_xgboost.tree_method and conf_params_xgboost.params[
"device"
] in ["gpu", "cuda"]:
Expand Down
Binary file modified dist/bluecast-1.6.0-py3-none-any.whl
Binary file not shown.
Binary file modified dist/bluecast-1.6.0.tar.gz
Binary file not shown.

0 comments on commit aaa6fb7

Please sign in to comment.