|
| 1 | +# Cargo Features |
| 2 | + |
| 3 | +**usls** is highly modular. Use feature flags to include only the models and hardware support you need, keeping your binary small and compilation fast. |
| 4 | + |
| 5 | +Features in ***italics*** are enabled by default. |
| 6 | + |
| 7 | +### Core & Utilities |
| 8 | + - ***`ort-download-binaries`***: Automatically download prebuilt ONNX Runtime binaries from [pyke](https://ort.pyke.io/perf/execution-providers). |
| 9 | + - **`ort-load-dynamic`**: Manually link ONNX Runtime. Useful for custom builds or unsupported platforms. See [Linking Guide](https://ort.pyke.io/setup/linking#static-linking) for more details. |
| 10 | + - **`viewer`**: Real-time image/video visualization (similar to OpenCV `imshow`). Empowered by [minifb](https://github.com/emoon/rust_minifb). |
| 11 | + - **`video`**: Video I/O support for reading and writing video streams. Empowered by [video-rs](https://github.com/oddity-ai/video-rs). |
| 12 | + - **`hf-hub`**: Download model files from Hugging Face Hub. |
| 13 | + - ***`annotator`***: Annotation utilities for drawing bounding boxes, keypoints, and masks on images. |
| 14 | + |
| 15 | +### Image Formats |
| 16 | +Additional image format support (optional for faster compilation): |
| 17 | + |
| 18 | + - **`image-all-formats`**: Enable all additional image formats. |
| 19 | + - **`image-gif`**, **`image-bmp`**, **`image-ico`**, **`image-avif`**, **`image-tiff`**, **`image-dds`**, **`image-exr`**, **`image-ff`**, **`image-hdr`**, **`image-pnm`**, **`image-qoi`**, **`image-tga**: Individual image format support. |
| 20 | + |
| 21 | +### Model Categories |
| 22 | + - ***`vision`***: Core vision models (Detection, Segmentation, Classification, Pose, etc.). |
| 23 | + - **`vlm`**: Vision-Language Models (CLIP, BLIP, Florence2, etc.). |
| 24 | + - **`mot`**: Multi-Object Tracking utilities. |
| 25 | + - **`all-models`**: Enable all model categories. |
| 26 | + |
| 27 | +### Execution Providers |
| 28 | +Hardware acceleration for inference. Enable the one matching your hardware: |
| 29 | + |
| 30 | + - **`cuda`**: NVIDIA CUDA execution provider (pure model inference acceleration). |
| 31 | + - **`tensorrt`**: NVIDIA TensorRT execution provider (pure model inference acceleration). |
| 32 | + - **`nvrtx`**: NVIDIA NvTensorRT-RTX execution provider (pure model inference acceleration). |
| 33 | + - **`cuda-full`**: `cuda` + `cuda-runtime-build` (Model + Image Preprocessing acceleration). |
| 34 | + - **`tensorrt-full`**: `tensorrt` + `cuda-runtime-build` (Model + Image Preprocessing acceleration). |
| 35 | + - **`nvrtx-full`**: `nvrtx` + `cuda-runtime-build` (Model + Image Preprocessing acceleration). |
| 36 | + - **`coreml`**: Apple Silicon (macOS/iOS). |
| 37 | + - **`openvino`**: Intel CPU/GPU/VPU. |
| 38 | + - **`onednn`**: Intel Deep Neural Network Library. |
| 39 | + - **`directml`**: DirectML (Windows). |
| 40 | + - **`webgpu`**: WebGPU (Web/Chrome). |
| 41 | + - **`rocm`**: AMD GPU acceleration. |
| 42 | + - **`cann`**: Huawei Ascend NPU. |
| 43 | + - **`rknpu`**: Rockchip NPU. |
| 44 | + - **`xnnpack`**: Mobile CPU optimization. |
| 45 | + - **`acl`**: Arm Compute Library. |
| 46 | + - **`armnn`**: Arm Neural Network SDK. |
| 47 | + - **`azure`**: Azure ML execution provider. |
| 48 | + - **`migraphx`**: AMD MIGraphX. |
| 49 | + - **`nnapi`**: Android Neural Networks API. |
| 50 | + - **`qnn`**: Qualcomm SNPE. |
| 51 | + - **`tvm`**: Apache TVM. |
| 52 | + - **`vitis`**: Xilinx Vitis AI. |
| 53 | + |
| 54 | +### CUDA Support |
| 55 | +NVIDIA GPU acceleration with CUDA image processing kernels (requires `cudarc`): |
| 56 | + |
| 57 | + - **`cuda-full`**: Uses `cuda-version-from-build-system` (auto-detects via `nvcc`). |
| 58 | + - **`cuda-11040`**, **`cuda-11050`**, **`cuda-11060`**, **`cuda-11070`**, **`cuda-11080`**: CUDA 11.x versions (Model + Preprocess). |
| 59 | + - **`cuda-12000`**, **`cuda-12010`**, **`cuda-12020`**, **`cuda-12030`**, **`cuda-12040`**, **`cuda-12050`**, **`cuda-12060`**, **`cuda-12080`**, **`cuda-12090`**: CUDA 12.x versions (Model + Preprocess). |
| 60 | + - **`cuda-13000`**, **`cuda-13010`**: CUDA 13.x versions (Model + Preprocess). |
| 61 | + |
| 62 | +### TensorRT Support |
| 63 | +NVIDIA TensorRT execution provider with CUDA runtime libraries: |
| 64 | + |
| 65 | + - **`tensorrt-full`**: Uses `cuda-version-from-build-system` (auto-detects via `nvcc`). |
| 66 | + - **`tensorrt-cuda-11040`**, **`tensorrt-cuda-11050`**, **`tensorrt-cuda-11060`**, **`tensorrt-cuda-11070`**, **`tensorrt-cuda-11080`**: TensorRT + CUDA 11.x runtime. |
| 67 | + - **`tensorrt-cuda-12000`**, **`tensorrt-cuda-12010`**, **`tensorrt-cuda-12020`**, **`tensorrt-cuda-12030`**, **`tensorrt-cuda-12040`**, **`tensorrt-cuda-12050`**, **`tensorrt-cuda-12060`**, **`tensorrt-cuda-12080`**, **`tensorrt-cuda-12090`**: TensorRT + CUDA 12.x runtime. |
| 68 | + - **`tensorrt-cuda-13000`**, **`tensorrt-cuda-13010`**: TensorRT + CUDA 13.x runtime. |
| 69 | + |
| 70 | + > **Note**: `tensorrt-cuda-*` features enable **TensorRT execution provider** with CUDA runtime libraries for image processing. The "cuda" in the name refers to `cudarc` dependency. |
| 71 | +
|
| 72 | +### NVRTX Support |
| 73 | +NVIDIA NvTensorRT-RTX execution provider with CUDA runtime libraries: |
| 74 | + |
| 75 | + - **`nvrtx-full`**: Uses `cuda-version-from-build-system` (auto-detects via `nvcc`). |
| 76 | + - **`nvrtx-cuda-11040`**, **`nvrtx-cuda-11050`**, **`nvrtx-cuda-11060`**, **`nvrtx-cuda-11070`**, **`nvrtx-cuda-11080`**: NVRTX + CUDA 11.x runtime. |
| 77 | + - **`nvrtx-cuda-12000`**, **`nvrtx-cuda-12010`**, **`nvrtx-cuda-12020`**, **`nvrtx-cuda-12030`**, **`nvrtx-cuda-12040`**, **`nvrtx-cuda-12050`**, **`nvrtx-cuda-12060`**, **`nvrtx-cuda-12080`**, **`nvrtx-cuda-12090`**: NVRTX + CUDA 12.x runtime. |
| 78 | + - **`nvrtx-cuda-13000`**, **`nvrtx-cuda-13010`**: NVRTX + CUDA 13.x runtime. |
| 79 | + |
| 80 | + > **Note**: `nvrtx-cuda-*` features enable **NVRTX execution provider** with CUDA runtime libraries for image processing. The "cuda" in the name refers to `cudarc` dependency. |
| 81 | +
|
| 82 | +--- |
| 83 | + |
| 84 | +## 🚀 Device Combination Guide |
| 85 | + |
| 86 | +| Scenario | Model Device (`--device`) | Processor Device (`--processor-device`) | Required Features (`-F`) | |
| 87 | +| :--- | :--- | :--- | :--- | |
| 88 | +| **CPU Only** | `cpu` | `cpu` | `vision` (default) | |
| 89 | +| **GPU Inference (Slow Preprocess)** | `cuda` | `cpu` | `cuda` | |
| 90 | +| **GPU Inference (Fast Preprocess)** | `cuda` | `cuda` | `cuda-full` or `cuda-120xxx` | |
| 91 | +| **TensorRT (Slow Preprocess)** | `tensorrt` | `cpu` | `tensorrt` | |
| 92 | +| **TensorRT (Fast Preprocess)** | `tensorrt` | `cuda` | `tensorrt-full` or `tensorrt-cuda-120xxx` | |
| 93 | + |
| 94 | +> ⚠️ In multi-GPU environments (e.g., `cuda:0`, `cuda:1`), you **MUST** ensure that both `--device` and `--processor-device` use the **SAME GPU ID**. |
| 95 | +
|
| 96 | +--- |
| 97 | + |
| 98 | +## Common Pitfalls |
| 99 | + |
| 100 | +```toml |
| 101 | +# ❌ Don't mix multiple CUDA versions |
| 102 | +features = ["cuda-12040", "cuda-11080"] |
| 103 | + |
| 104 | +# ✅ Use one execution provider |
| 105 | +features = ["tensorrt-full"] |
| 106 | + |
| 107 | +# ✅ Use two execution provider: cuda EP + tensorrt EP + cuda image processing |
| 108 | +features = ["cuda-full", "tensorrt"] |
| 109 | +features = ["cuda", "tensorrt-full"] |
| 110 | + |
| 111 | + |
| 112 | +``` |
0 commit comments