Environment:Kornia Kornia PyTorch Python Environment
| Knowledge Sources | |
|---|---|
| Domains | Infrastructure, Computer_Vision |
| Last Updated | 2026-02-09 15:00 GMT |
Overview
Python 3.11+ environment with PyTorch >= 2.0.0 and kornia_rs >= 0.1.9 native backend for differentiable computer vision.
Description
This is the core runtime environment required to use the Kornia library. Kornia is built entirely on top of PyTorch and requires a modern Python runtime (3.11 or newer). The library uses a Rust-based native extension (kornia_rs) for high-performance image I/O operations using libjpeg-turbo and other native codecs. The packaging library is also required for version comparison utilities used internally by Kornia's compatibility layer.
Usage
Use this environment for any Kornia operation. This is the base prerequisite for all Kornia workflows including image augmentation, feature matching, edge detection, and ONNX pipelines. Every Implementation page in the Kornia wiki requires this environment.
System Requirements
| Category | Requirement | Notes |
|---|---|---|
| OS | Linux, macOS, Windows | Cross-platform; `kornia_rs` provides native binaries per OS |
| Hardware | CPU (minimum) | GPU optional; see CUDA_GPU_Environment for GPU acceleration |
| Disk | ~500MB | For PyTorch + Kornia + kornia_rs installation |
Dependencies
System Packages
- No special system packages required for CPU-only usage
- For `kornia_rs` image I/O: libjpeg-turbo is bundled in the wheel
Python Packages
- `python` >= 3.11 (supports 3.11, 3.12, 3.13)
- `torch` >= 2.0.0
- `kornia_rs` >= 0.1.9
- `packaging` (any version)
Credentials
No credentials are required for core Kornia functionality.
Quick Install
# Install Kornia (automatically pulls torch, kornia_rs, packaging)
pip install kornia
# Or install with specific PyTorch version
pip install torch>=2.0.0 kornia
Code Evidence
Python version requirement from `pyproject.toml:9`:
requires-python = ">=3.11"
Core dependencies from `pyproject.toml:32`:
dependencies = ["kornia_rs>=0.1.9", "packaging", "torch>=2.0.0"]
PyTorch version comparison utilities from `kornia/core/_compat.py:74-102`:
def torch_version_ge(major: int, minor: int, patch: Optional[int] = None) -> bool:
"""Check if the current PyTorch version is greater than or equal to the specified version."""
_version = version.parse(torch_version())
if patch is None:
return _version >= version.parse(f"{major}.{minor}")
else:
return _version >= version.parse(f"{major}.{minor}.{patch}")
kornia_rs is imported directly (not lazy-loaded) for image I/O from `kornia/io/io.py:24`:
import kornia_rs
Common Errors
| Error Message | Cause | Solution |
|---|---|---|
| `ModuleNotFoundError: No module named 'kornia_rs'` | kornia_rs native extension not installed | `pip install kornia_rs>=0.1.9` |
| `RuntimeError: Dynamo is not supported on Python 3.12+` | torch.compile limitation on newer Python | Downgrade to Python 3.11 or disable torch.compile |
| `ImportError: torch` | PyTorch not installed | `pip install torch>=2.0.0` |
Compatibility Notes
- Python 3.11+: Required minimum. Python 3.10 and earlier are not supported.
- PyTorch JIT Scripting: Kornia uses `Optional[]`, `Union[]`, `List[]` typing syntax (not `X | None`) for compatibility with `torch.jit.script`. This is documented in `pyproject.toml` ruff ignore rules `UP006`, `UP007`, `UP035`.
- torch.compile: Supported but may have issues on Python 3.12+. Kornia avoids in-place operations in critical paths to maintain `torch.compile()` compatibility.
- MPS (Apple Silicon): Supported with fallbacks. Some operations like `torch.std_mean` have MPS-specific workarounds via `is_mps_tensor_safe()`.
Related Pages
- Implementation:Kornia_Kornia_Load_Image
- Implementation:Kornia_Kornia_Augmentation_Transforms_2D
- Implementation:Kornia_Kornia_AugmentationSequential
- Implementation:Kornia_Kornia_RandAugment_TrivialAugment
- Implementation:Kornia_Kornia_AugmentationSequential_Forward
- Implementation:Kornia_Kornia_Tensor_To_Image
- Implementation:Kornia_Kornia_Rgb_To_Grayscale
- Implementation:Kornia_Kornia_LoFTR
- Implementation:Kornia_Kornia_ScaleSpaceDetector
- Implementation:Kornia_Kornia_Feature_Matching_Functions
- Implementation:Kornia_Kornia_RANSAC
- Implementation:Kornia_Kornia_Inlier_Mask_Indexing
- Implementation:Kornia_Kornia_ImageStitcher
- Implementation:Kornia_Kornia_ONNXLoader_Load_Model
- Implementation:Kornia_Kornia_IO_Maps_Configuration
- Implementation:Kornia_Kornia_ONNXSequential
- Implementation:Kornia_Kornia_ONNXSequential_Call
- Implementation:Kornia_Kornia_ONNXSequential_Export
- Implementation:Kornia_Kornia_Canny_Edge_Detector
- Implementation:Kornia_Kornia_Sobel_Operator
- Implementation:Kornia_Kornia_DexiNed_Detector
- Implementation:Kornia_Kornia_Edge_Map_Processing