Skip to content

[BUG]: PyCaret ImportError displays incorrect version when cuML isn't available and use_gpu="force" #3422

@beckernick

Description

@beckernick

pycaret version checks

Issue Description

If cuML is not available and a user runs use_gpu="force", this line will grab the version of PyCaret rather than cuML. This was brought to my attention by a user in rapidsai/cuml#5289

The ImportError thrown includes a clear statement of the problem, so there may not be a need to provide any version information beyond "cuML is outdated or not found. Required version is >=22.10".

Please feel free to assign this issue to me :)

Reproducible Example

from pycaret.datasets import get_data
data = get_data('diabetes')

from pycaret.classification import *
s = setup(data, target = 'Class variable', use_gpu="force")

Expected Behavior

I expect the ImportError to essentially be the same, without showing the PyCaret version.

Actual Results

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
Input In [2], in <cell line: 2>()
      1 from pycaret.classification import *
----> 2 s = setup(data, target = 'Class variable', use_gpu="force")

File ~/NVIDIA/pycaret/pycaret/classification/functional.py:596, in setup(data, data_func, target, index, train_size, test_data, ordinal_features, numeric_features, categorical_features, date_features, text_features, ignore_features, keep_features, preprocess, create_date_columns, imputation_type, numeric_imputation, categorical_imputation, iterative_imputation_iters, numeric_iterative_imputer, categorical_iterative_imputer, text_features_method, max_encoding_ohe, encoding_method, rare_to_value, rare_value, polynomial_features, polynomial_degree, low_variance_threshold, group_features, group_names, remove_multicollinearity, multicollinearity_threshold, bin_numeric_features, remove_outliers, outliers_method, outliers_threshold, fix_imbalance, fix_imbalance_method, transformation, transformation_method, normalize, normalize_method, pca, pca_method, pca_components, feature_selection, feature_selection_method, feature_selection_estimator, n_features_to_select, custom_pipeline, custom_pipeline_position, data_split_shuffle, data_split_stratify, fold_strategy, fold, fold_shuffle, fold_groups, n_jobs, use_gpu, html, session_id, system_log, log_experiment, experiment_name, experiment_custom_tags, log_plots, log_profile, log_data, verbose, memory, profile, profile_kwargs)
    594 exp = _EXPERIMENT_CLASS()
    595 set_current_experiment(exp)
--> 596 return exp.setup(
    597     data=data,
    598     data_func=data_func,
    599     target=target,
    600     index=index,
    601     train_size=train_size,
    602     test_data=test_data,
    603     ordinal_features=ordinal_features,
    604     numeric_features=numeric_features,
    605     categorical_features=categorical_features,
    606     date_features=date_features,
    607     text_features=text_features,
    608     ignore_features=ignore_features,
    609     keep_features=keep_features,
    610     preprocess=preprocess,
    611     create_date_columns=create_date_columns,
    612     imputation_type=imputation_type,
    613     numeric_imputation=numeric_imputation,
    614     categorical_imputation=categorical_imputation,
    615     iterative_imputation_iters=iterative_imputation_iters,
    616     numeric_iterative_imputer=numeric_iterative_imputer,
    617     categorical_iterative_imputer=categorical_iterative_imputer,
    618     text_features_method=text_features_method,
    619     max_encoding_ohe=max_encoding_ohe,
    620     encoding_method=encoding_method,
    621     rare_to_value=rare_to_value,
    622     rare_value=rare_value,
    623     polynomial_features=polynomial_features,
    624     polynomial_degree=polynomial_degree,
    625     low_variance_threshold=low_variance_threshold,
    626     group_features=group_features,
    627     group_names=group_names,
    628     remove_multicollinearity=remove_multicollinearity,
    629     multicollinearity_threshold=multicollinearity_threshold,
    630     bin_numeric_features=bin_numeric_features,
    631     remove_outliers=remove_outliers,
    632     outliers_method=outliers_method,
    633     outliers_threshold=outliers_threshold,
    634     fix_imbalance=fix_imbalance,
    635     fix_imbalance_method=fix_imbalance_method,
    636     transformation=transformation,
    637     transformation_method=transformation_method,
    638     normalize=normalize,
    639     normalize_method=normalize_method,
    640     pca=pca,
    641     pca_method=pca_method,
    642     pca_components=pca_components,
    643     feature_selection=feature_selection,
    644     feature_selection_method=feature_selection_method,
    645     feature_selection_estimator=feature_selection_estimator,
    646     n_features_to_select=n_features_to_select,
    647     custom_pipeline=custom_pipeline,
    648     custom_pipeline_position=custom_pipeline_position,
    649     data_split_shuffle=data_split_shuffle,
    650     data_split_stratify=data_split_stratify,
    651     fold_strategy=fold_strategy,
    652     fold=fold,
    653     fold_shuffle=fold_shuffle,
    654     fold_groups=fold_groups,
    655     n_jobs=n_jobs,
    656     use_gpu=use_gpu,
    657     html=html,
    658     session_id=session_id,
    659     system_log=system_log,
    660     log_experiment=log_experiment,
    661     experiment_name=experiment_name,
    662     experiment_custom_tags=experiment_custom_tags,
    663     log_plots=log_plots,
    664     log_profile=log_profile,
    665     log_data=log_data,
    666     verbose=verbose,
    667     memory=memory,
    668     profile=profile,
    669     profile_kwargs=profile_kwargs,
    670 )

File ~/NVIDIA/pycaret/pycaret/classification/oop.py:721, in ClassificationExperiment.setup(self, data, data_func, target, index, train_size, test_data, ordinal_features, numeric_features, categorical_features, date_features, text_features, ignore_features, keep_features, preprocess, create_date_columns, imputation_type, numeric_imputation, categorical_imputation, iterative_imputation_iters, numeric_iterative_imputer, categorical_iterative_imputer, text_features_method, max_encoding_ohe, encoding_method, rare_to_value, rare_value, polynomial_features, polynomial_degree, low_variance_threshold, group_features, group_names, remove_multicollinearity, multicollinearity_threshold, bin_numeric_features, remove_outliers, outliers_method, outliers_threshold, fix_imbalance, fix_imbalance_method, transformation, transformation_method, normalize, normalize_method, pca, pca_method, pca_components, feature_selection, feature_selection_method, feature_selection_estimator, n_features_to_select, custom_pipeline, custom_pipeline_position, data_split_shuffle, data_split_stratify, fold_strategy, fold, fold_shuffle, fold_groups, n_jobs, use_gpu, html, session_id, system_log, log_experiment, experiment_name, experiment_custom_tags, log_plots, log_profile, log_data, engine, verbose, memory, profile, profile_kwargs)
    718 self.fold_shuffle_param = fold_shuffle
    719 self.fold_groups_param = fold_groups
--> 721 self._initialize_setup(
    722     n_jobs=n_jobs,
    723     use_gpu=use_gpu,
    724     html=html,
    725     session_id=session_id,
    726     system_log=system_log,
    727     log_experiment=log_experiment,
    728     experiment_name=experiment_name,
    729     memory=memory,
    730     verbose=verbose,
    731 )
    733 # Prepare experiment specific params ======================= >>
    735 self.log_plots_param = log_plots

File ~/NVIDIA/pycaret/pycaret/internal/pycaret_experiment/tabular_experiment.py:354, in _TabularExperiment._initialize_setup(self, n_jobs, use_gpu, html, session_id, system_log, log_experiment, experiment_name, memory, verbose)
    352 message = f"cuML is outdated or not found. Required version is >=22.10, got {__version__}"
    353 if use_gpu == "force":
--> 354     raise ImportError(message)
    355 else:
    356     self.logger.warning(message)

ImportError: cuML is outdated or not found. Required version is >=22.10, got 3.0.0.rc4

Installed Versions

System: python: 3.10.9 | packaged by conda-forge | (main, Feb 2 2023, 20:20:04) [GCC 11.3.0] executable: /home/nicholasb/miniconda3/envs/pycaret/bin/python machine: Linux-5.8.0-38-generic-x86_64-with-glibc2.31

PyCaret required dependencies:
pip: 23.0.1
setuptools: 67.6.0
pycaret: 3.0.0
IPython: 8.4.0
ipywidgets: 8.0.5
tqdm: 4.65.0
numpy: 1.23.5
pandas: 1.5.3
jinja2: 3.1.2
scipy: 1.10.1
joblib: 1.2.0
sklearn: 1.2.2
pyod: 1.0.9
imblearn: 0.10.1
category_encoders: 2.6.0
lightgbm: 3.3.5
numba: 0.56.4
requests: 2.28.2
matplotlib: 3.7.1
scikitplot: 0.3.7
yellowbrick: 1.5
plotly: 5.13.1
kaleido: 0.2.1
statsmodels: 0.13.5
sktime: 0.16.1
tbats: 1.1.2
pmdarima: 2.0.3
psutil: 5.9.4

PyCaret optional dependencies:
shap: Not installed
interpret: Not installed
umap: Not installed
pandas_profiling: Not installed
explainerdashboard: Not installed
autoviz: Not installed
fairlearn: Not installed
xgboost: Not installed
catboost: Not installed
kmodes: Not installed
mlxtend: Not installed
statsforecast: Not installed
tune_sklearn: Not installed
ray: Not installed
hyperopt: Not installed
optuna: Not installed
skopt: Not installed
mlflow: Not installed
gradio: Not installed
fastapi: Not installed
uvicorn: Not installed
m2cgen: Not installed
evidently: Not installed
nltk: Not installed
pyLDAvis: Not installed
gensim: Not installed
spacy: Not installed
wordcloud: Not installed
textblob: Not installed
fugue: Not installed
streamlit: Not installed
prophet: Not installed

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions