h2oai / h2o4gpu

H2Oai GPU Edition
Apache License 2.0
460 stars 95 forks source link

Low GPU utilization during Random Forest predict #843

Open StargazerAlex opened 4 years ago

StargazerAlex commented 4 years ago

Environment (for bugs)

Description

I want to use the Random Forest Classifier for predictions on a large amount of data but the prediction phase takes oddly much time and shows very low GPU utilization. Here are the parameters I used for training:

model = h2o4gpu.RandomForestClassifier(
    n_estimators = 100, criterion = "gini",
    max_depth = 8, min_samples_split = 2, min_samples_leaf = 1,
    min_weight_fraction_leaf = 0, max_features = "auto",
    max_leaf_nodes = None, min_impurity_decrease = 0,
    min_impurity_split = None, bootstrap = True, oob_score = False,
    n_jobs = -1, random_state = None, verbose = 0, warm_start = False,
    class_weight = None, subsample = 1, colsample_bytree = 1,
    num_parallel_tree = 1, tree_method = "gpu_hist", n_gpus = -1,
    predictor = "gpu_predictor", backend = "h2o4gpu")

model.fit(x_train, y_train)

The training works pretty well. It's comparably fast and constantly uses around 80% of the GPU (measured with nvidia-smi).

y_pred = model.predict(x_test)

The prediction however only utilizes 4% of the GPU for a fraction of the time it requires to do one iteration (across 10 samples) while it mostly seems to use the CPU with being constantly at 100% for one core. For a class size of 2 it takes around 0.4 seconds, for 10 classes it is 3.4 seconds. Running it on solely CPU-based scikit-learn is faster with only 0.1 seconds.

Is this a general problem of tree-based predictions or am I doing something wrong?

Thanks a lot in advance!