Skip to content

refactor: use tensorrt-rs from kornia/tensorrt-rs instead of the in-tree trt-sys - #29

Merged
edgarriba merged 2 commits into
kornia:mainfrom
arc-wonders:refactor/trt-sys-from-tensorrt-rs
Oct 4, 2026
Merged

edgarriba merged 2 commits into
kornia:mainfrom
arc-wonders:refactor/trt-sys-from-tensorrt-rs

Conversation

@arc-wonders

Copy link
Copy Markdown
Contributor

Follow-up to kornia/tensorrt-rs#1. Removes the in-tree crates/trt-sys and makes vrt use tensorrt-rs from kornia/tensorrt-rs instead.

  • crates/trt-sys/ deleted and dropped from the workspace.
  • vrt depends on tensorrt-rs = { git = "https://github.com/kornia/tensorrt-rs", branch = "main" }, imports are tensorrt_rs:: now.
  • trt-sys path patch removed from the five examples/rtsp_* manifests, all six lockfiles refreshed (they resolve to 688a1e8).
  • -p trt-sys dropped from CI, docs and comments updated to the new name.

No breaking changes for users of vrt or the model crates.

Testing

Ran the same steps on main (d9e46b4) and on this branch against a real TensorRT, each from an empty engine cache.

main this branch
real build (C++ shims, bindgen, link libnvinfer + libnvonnxparser) ok ok
cargo test -p vrt-xfeat --release --lib -- --ignored 4 passed 4 passed
cargo test -p vrt-raco-aliked --release --test gpu_fit -- --ignored 4 passed 4 passed
rfdetr_detect (ONNX -> engine -> inference) 5 detections same 5 detections, same scores and boxes
raco_detect (ONNX -> engine -> inference) 1024 keypoints 1024 keypoints

All CI steps also pass locally in stub mode (fmt, check, both clippy runs, the three test steps).

System

OS Ubuntu 26.04 LTS, kernel 7.0.0-31, x86_64
CPU / RAM Intel Core i7-13700HX, 14 GB
GPU NVIDIA GeForce RTX 4060 Laptop, 8 GB (sm89)
Driver 595.91.07 (CUDA 13.2)
CUDA toolkit 13.3
TensorRT 10.13.3.9 (tar, Linux.x86_64-gnu.cuda-13.0)
Rust 1.93.0 (from rust-toolchain.toml), gcc 15.2.0

Env used for the real build:

export TRT_INCLUDE_DIR=$HOME/tensorrt/TensorRT-10.13.3.9/include
export TRT_LIB_DIR=$HOME/tensorrt/TensorRT-10.13.3.9/lib
export CUDA_HOME=/usr/local/cuda
# libclang here ships without its own headers
export BINDGEN_EXTRA_CLANG_ARGS="-I/usr/lib/gcc/x86_64-linux-gnu/15/include"
# NVRTC 13.1 first: the driver (CUDA 13.2) rejects PTX from the toolkit's NVRTC 13.3
export LD_LIBRARY_PATH=$HOME/tensorrt/nvrtc-13.0/nvidia/cu13/lib:$TRT_LIB_DIR:/usr/local/cuda/lib64

Proof of run (this branch)

build: tensorrt-rs pulled from git, linked against real TensorRT
$ cargo build --release -p vrt -p vrt-hub -p vrt-xfeat -p vrt-rfdetr -p vrt-raco-aliked --features vrt-hub/builder
   Compiling tensorrt-rs v0.1.0 (https://github.com/kornia/tensorrt-rs?branch=main#688a1e8d)
   Compiling vrt v0.1.0 (/home/arkin/kornia/vision-rt/crates/vrt)
    Finished `release` profile [optimized] target(s) in 18.28s

$ ldd target/release/examples/rfdetr_detect | grep -E "nvinfer|nvonnx"
	libnvinfer.so.10 => /home/arkin/tensorrt/TensorRT-10.13.3.9/lib/libnvinfer.so.10
	libnvonnxparser.so.10 => /home/arkin/tensorrt/TensorRT-10.13.3.9/lib/libnvonnxparser.so.10
GPU tests
$ cargo test -p vrt-xfeat --release --lib -- --ignored --nocapture
running 4 tests
test matching::tests::gpu_match_kernel_only_timing ... ok
test postprocess::gpu_compact_tests::gpu_topk_selects_correct_keypoints ... ok
test matching::tests::gpu_match_agrees_with_cpu_reference ... ok
test matching::tests::gpu_match_128d_agrees_with_cpu_reference ... ok
test result: ok. 4 passed; 0 failed; 0 ignored; 0 measured; 5 filtered out; finished in 3.61s

$ cargo test -p vrt-raco-aliked --release --test gpu_fit -- --ignored --nocapture
running 4 tests
test alternate_kernels_match_host ... ok
test crop_only_matches_host ... ok
test downscale_matches_host ... ok
test report_fit_timing ... ok
test result: ok. 4 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.24s
RF-DETR and RaCo-ALIKED on COCO val2017 000000039769 (two cats, two remotes)
$ cargo run --release -p vrt-rfdetr --example rfdetr_detect -- rf-detr-small.onnx 000000039769.jpg 0.5
[vision-rt] building engine for 'rfdetr' (one-time, ~1-5 min): ~/.cache/vision-rt/engines/rfdetr-0e0817f4-7e4c7202-trt10.3.0.30-sm89.engine
640x480 → 5 detections (conf ≥ 0.5, 300 queries)
  class  17  score 0.963  box [11,55,319,473]
  class  17  score 0.932  box [347,24,640,374]
  class  75  score 0.886  box [41,72,176,118]
  class  75  score 0.835  box [334,77,371,187]
  class  65  score 0.594  box [2,1,641,476]

$ cargo run --release -p vrt-raco-aliked --example raco_detect -- raco_aliked_extractor_k1024.onnx 000000039769.jpg out.png
[vision-rt] building engine for 'raco-aliked-extractor' (one-time, ~1-5 min): ~/.cache/vision-rt/engines/raco-aliked-extractor-33d78890-cadeea53-trt10.3.0.30-sm89.engine
640x480 → 1024 keypoints (K is fixed by the engine; stretch ratio 1.000x1.000)
saved out.png

main prints the same detections, scores and boxes. ONNX files are the ones pinned in vrt-hub (sha256 checked).

Not covered

  • Jetson (aarch64, TensorRT 10.3), I don't have one.
  • XFeat end to end: its ONNX fails to parse on TensorRT 10.13 (Invalid Node - node_Range_427). Same on main and with trtexec, so unrelated to this change. The XFeat GPU kernel tests above do pass.
  • The engine names say trt10.3.0.30 because the build script can't read the version from the 10.13 headers and falls back. Same on main.

Use case: I did the trt-sys -> tensorrt-rs move and this is the second half of it.

🤖 Generated with Claude Code

Comment thread crates/vrt/Cargo.toml Outdated

@edgarriba edgarriba left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pinned to v0.1.0, thanks.

@edgarriba
edgarriba merged commit db8233b into kornia:main Oct 4, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants