fix(cuda): учтён отказ по неподдерживаемому типу вычислений

This commit is contained in:
Dmitry Dementiev committed 2026-09-21 23:20:51 +03:00
1 parent 453b5d9dfa
commit a8b8a8c0c9
5 files changed
+70 -15

No files matched your search

+7 -6
View File
@@ -65,9 +65,9 @@ app = typer.Typer()
console = Console(stderr=True)
def _print_cuda_hint(exc: BaseException) -> None:
def _print_cuda_hint(exc: BaseException, device: str | None = None) -> None:
"""Показывает подсказку, не заменяя исходную ошибку."""
hint = cuda_error_hint(exc)
hint = cuda_error_hint(exc, device=device)
if hint:
console.print(hint, style="yellow", markup=False)
@@ -348,6 +348,7 @@ def main(
)
raise SystemExit(2)
resolved_device: str | None = None
try:
config = load_config()
cli_values: CliValues = {
@@ -405,15 +406,15 @@ def main(
except SystemExit:
raise
except ValueError as exc:
_print_cuda_hint(exc)
_print_cuda_hint(exc, resolved_device)
console.print(f"Ошибка: {exc}", style="red bold")
raise SystemExit(1)
except (FileNotFoundError,) as exc:
_print_cuda_hint(exc)
_print_cuda_hint(exc, resolved_device)
console.print(f"Ошибка: {exc}", style="red bold")
raise SystemExit(1)
except Exception as exc:
_print_cuda_hint(exc)
_print_cuda_hint(exc, resolved_device)
if verbose:
console.print_exception()
else:
@@ -759,7 +760,7 @@ def _run_batch(
except KeyboardInterrupt:
raise
except Exception as exc:
_print_cuda_hint(exc)
_print_cuda_hint(exc, actual_device)
if verbose:
console.print_exception()
else:
+9 -1
View File
@@ -195,9 +195,17 @@ def _is_cuda_error(exc: BaseException) -> bool:
return any(k in msg for k in ("cuda", "cublas", "cudnn", "out of memory"))
def cuda_error_hint(exc: BaseException) -> str | None:
def cuda_error_hint(exc: BaseException, *, device: str | None = None) -> str | None:
"""Подсказывает действие только для распознанной причины CUDA-ошибки."""
msg = str(exc).lower()
if device == "cuda" and "requested " in msg and "compute type" in msg and (
"do not support efficient" in msg
):
return (
"Тип вычислений несовместим с выбранным GPU/CUDA runtime. "
"Установка extra не добавит аппаратную поддержку. Выберите "
"поддерживаемый --compute-type или --device onnx / --device cpu."
)
if any(k in msg for k in (
"no kernel image", "invalid device function", "unsupported gpu",
"cublas_status_arch_mismatch", "cuda_error_no_binary_for_gpu",