Skip to content

Error with gpu-enabled xgboost #1235

Open
@mitchellmanware

Description

@mitchellmanware

The problem

I am getting an error message when implementing tidymodels functions for xgboost boosted tree model with GPU acceleration. Error reports problem with evals parameter in xgb.train

Reproducible example

Utilizing GPU-enabled xgboost version 2.1.3, accessed from Releases.
Package installation:

# Build and install xgboost with GPU support
wget https://github.com/dmlc/xgboost/releases/download/v2.1.3/xgboost_r_gpu_linux_2.1.3.tar.gz    
Rscript -e "install.packages(c('data.table', 'jsonlite'))"
R CMD INSTALL ./xgboost_r_gpu_linux_2.1.3.tar.gz

Reprex with credit_data example data:

> library(xgboost); library(tibble); library(rsample); library(dplyr); library(purrr); library(parsnip); library(recipes); library(workflows); library(dials); library(tune); library(yardstick); library(tidymodels)
> data(credit_data, package = "modeldata")
> credit <- credit_data |> tibble::as_tibble()
> credit_split <- rsample::initial_split(
          credit, prop = 0.8, strata = "Status"
        )
> train <- rsample::training(credit_split)
        test <- rsample::testing(credit_split)
> cv_split <- rsample::vfold_cv(
          train, v = 5, repeats = 2, strata = "Status"
        )
> scaler <- train |>
          dplyr::count(Status) |>
          dplyr::pull(n) |>
          purrr::reduce(`/`)
> xg_spec <- parsnip::boost_tree(
          mode = "classification",
          trees = parsnip::tune(),
          tree_depth = parsnip::tune(),
          sample_size = parsnip::tune()
        ) |>
          parsnip::set_engine(
            "xgboost",
            params = list(tree_method = "gpu_hist"),
            scale_pos_weight = scaler
          )
> rec_xg_flow <- recipes::recipe(Status ~ ., data = train) |>
          recipes::step_unknown(
            all_nominal_predictors(), new_level = "missing"
          ) |>
          recipes::step_novel(all_nominal_predictors(), new_level = "Unseen") |>
          recipes::step_other(all_nominal_predictors(), other = "Misc") |>
          recipes::step_dummy(all_nominal_predictors(), one_hot = TRUE)
> xg_flow <- workflows::workflow(
          preprocessor = rec_xg_flow, spec = xg_spec
        )
> xg_trees <- dials::trees(range = c(10, 300))
        xg_tree_depth <- dials::tree_depth(range = c(2, 8))
        xg_sample_size <- dials::sample_prop(range = c(0.3, 1.0))
        xg_params <- dials::parameters(xg_trees, xg_tree_depth, xg_sample_size)
> xg_tune <- tune::tune_grid(
          xg_flow,
          resamples = cv_split,
          param_info = xg_params,
          metrics = yardstick::metric_set(
            yardstick::roc_auc, yardstick::accuracy
          ),
          grid = 30,
          control = tune::control_grid(allow_par = TRUE, save_pred = TRUE)
        )
→ A | error:   <text>:1:10: unexpected '<'
               1: evals <- <
                            ^
There were issues with some computations   A: x300
Warning message:
All models failed. Run `show_notes(.Last.tune.result)` for more information.
> tune::show_notes(.Last.tune.result)
unique notes:
───────────────────────────
<text>:1:10: unexpected '<'
1: evals <- <
             ^

Reprex derived from GPU Computing with R presentation (slides 61 - 75)
@sigmafelix @kyle-messier

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugan unexpected problem or unintended behavior

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions