Skip to content

🐍 Geometric Computer Vision Library for Spatial AI

docs(onnx): as_tensorrt on onnxruntime-gpu without TensorRT, load's ONNXModule link, Resize on torch 2.5 (#6178)

Dmytro Mishkin0909ff251330
diff --git a/docs/source/augmentation.rst b/docs/source/augmentation.rst
index 6092c2b1b..8c3742286 100644
--- a/docs/source/augmentation.rst
+++ b/docs/source/augmentation.rst
@@ -96,9 +96,9 @@ Kornia augmentations are plain ``nn.Module`` s and are exportable for deployment
- **ONNX.** :class:`~kornia.onnx.sequential.ONNXSequential` chains ONNX graphs; it does not take an augmentation
module. The :ref:`export survey <export-support>` records which individual augmentations exported. Without
``dynamic_shapes``, a pipeline exported with ``torch.onnx.export(..., dynamo=True)`` gets a graph of the input shape
- it was exported with, and some augmentations (``Resize``, for one) keep that shape fixed even with it. Some
- augmentations fail to export. The exported file can be chained with ``ONNXSequential``. Pre-built ONNX
- models are published under the ``kornia/ONNX_models`` Hugging Face repo.
+ it was exported with, and some augmentations (``Resize``, for one) keep that shape fixed even with it, or fail to
+ export with it on torch 2.5.1. Some augmentations fail to export. The exported file can be chained with
+ ``ONNXSequential``. Pre-built ONNX models are published under the ``kornia/ONNX_models`` Hugging Face repo.
.. currentmodule:: kornia.augmentation
diff --git a/kornia/core/mixin/onnx.py b/kornia/core/mixin/onnx.py
index fee9cab61..5817fd75b 100644
--- a/kornia/core/mixin/onnx.py
+++ b/kornia/core/mixin/onnx.py
@@ -648,7 +648,10 @@ class ONNXRuntimeMixin:
"""Set the session to run on TensorRT.
We set the ONNX runtime session to use TensorrtExecutionProvider. If the installed onnxruntime build does not
- offer it, nothing raises: onnxruntime warns and the session runs on the CPU.
+ offer it, nothing raises: onnxruntime warns and the session runs on the CPU. A build that offers it but cannot
+ load the TensorRT libraries, such as ``onnxruntime-gpu`` without TensorRT installed, raises onnxruntime's
+ ``RuntimeError`` and leaves the session unusable: a call then raises ``TypeError`` until another ``as_*`` call,
+ such as :meth:`as_cpu` or :meth:`as_cuda`.
For other TensorrtExecutionProvider configurations, or CUDA/cuDNN/ONNX/TensorRT version issues,
you may refer to https://onnxruntime.ai/docs/execution-providers/TensorRT-ExecutionProvider.html.
diff --git a/kornia/onnx/module.py b/kornia/onnx/module.py
index 829073ef4..eb77374be 100644
--- a/kornia/onnx/module.py
+++ b/kornia/onnx/module.py
@@ -138,7 +138,8 @@ def load(model_name: Union[onnx.ModelProto, str, os.PathLike], *, force_download
force_download: If True, download the model again and replace the cached file, even when it is cached.
Note:
- Given an ``onnx.ModelProto``, the module holds that object itself; see the note of :class:`ONNXModule`.
+ Given an ``onnx.ModelProto``, the module holds that object itself; see the note of
+ :class:`~kornia.onnx.module.ONNXModule`.
"""
return ONNXModule(model_name, force_download=force_download)