From e142954bf450e25e1ac1211d3aa4c6cf75647f2d Mon Sep 17 00:00:00 2001 From: allegroai <> Date: Sun, 6 Mar 2022 19:33:11 +0200 Subject: [PATCH] Fix failed catboost bind on GPU (#592) --- clearml/binding/frameworks/catboost_bind.py | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/clearml/binding/frameworks/catboost_bind.py b/clearml/binding/frameworks/catboost_bind.py index 0ac8f4c4..d83e5ac9 100644 --- a/clearml/binding/frameworks/catboost_bind.py +++ b/clearml/binding/frameworks/catboost_bind.py @@ -39,10 +39,9 @@ def _patch_model_io(): CatBoostClassifier.fit = _patched_call(CatBoostClassifier.fit, PatchCatBoostModelIO._fit) CatBoostRegressor.fit = _patched_call(CatBoostRegressor.fit, PatchCatBoostModelIO._fit) CatBoostRanker.fit = _patched_call(CatBoostRegressor.fit, PatchCatBoostModelIO._fit) - except ImportError: - pass - except Exception: - pass + except Exception as e: + logger = PatchCatBoostModelIO.__main_task.get_logger() + logger.report_text("Failed patching Catboost. Exception is: '" + str(e) + "'") @staticmethod def _save(original_fn, obj, f, *args, **kwargs): @@ -94,7 +93,17 @@ def _load(original_fn, f, *args, **kwargs): def _fit(original_fn, obj, *args, **kwargs): callbacks = kwargs.get("callbacks") or [] kwargs["callbacks"] = callbacks + [PatchCatBoostModelIO.__callback_cls(task=PatchCatBoostModelIO.__main_task)] - return original_fn(obj, *args, **kwargs) + # noinspection PyBroadException + try: + return original_fn(obj, *args, **kwargs) + except Exception: + logger = PatchCatBoostModelIO.__main_task.get_logger() + logger.report_text( + "Catboost metrics logging is not supported for GPU. " + "See https://github.com/catboost/catboost/issues/1792" + ) + del kwargs["callbacks"] + return original_fn(obj, *args, **kwargs) @staticmethod def _generate_training_callback_class():