{"id":30783272,"url":"https://github.com/saronic-technologies/libinfer","last_synced_at":"2025-09-05T10:05:37.388Z","repository":{"id":234317258,"uuid":"758040984","full_name":"saronic-technologies/libinfer","owner":"saronic-technologies","description":null,"archived":false,"fork":false,"pushed_at":"2025-09-04T17:12:58.000Z","size":11984,"stargazers_count":1,"open_issues_count":6,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-09-04T19:16:16.607Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/saronic-technologies.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2024-02-15T14:06:01.000Z","updated_at":"2025-09-03T21:06:38.000Z","dependencies_parsed_at":"2024-04-18T21:27:24.813Z","dependency_job_id":"270d3133-caa5-42ce-9ee8-ca9c03dfeb10","html_url":"https://github.com/saronic-technologies/libinfer","commit_stats":null,"previous_names":["saronic-technologies/libinfer"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/saronic-technologies/libinfer","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/saronic-technologies%2Flibinfer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/saronic-technologies%2Flibinfer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/saronic-technologies%2Flibinfer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/saronic-technologies%2Flibinfer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/saronic-technologies","download_url":"https://codeload.github.com/saronic-technologies/libinfer/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/saronic-technologies%2Flibinfer/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273740477,"owners_count":25159432,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-05T02:00:09.113Z","response_time":402,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-09-05T10:04:36.644Z","updated_at":"2025-09-05T10:05:37.372Z","avatar_url":"https://github.com/saronic-technologies.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# `libinfer`\nThis library provides a simple Rust interface to a TensorRT engine using [cxx](https://cxx.rs/)\n\n## Overview\n`libinfer` allows for seamless integration of TensorRT models into Rust applications with minimal overhead. The library handles the complex C++ interaction with TensorRT while exposing a simple, idiomatic Rust API.\n\n## Installation\nTo use this library, you'll need:\n- CUDA and TensorRT installed on your system\n- Environment variables set properly:\n  - `TENSORRT_LIBRARIES`: Path to TensorRT libraries\n  - `CUDA_LIBRARIES`: Path to CUDA libraries\n  - `CUDA_INCLUDE_DIRS`: Path to CUDA include directories\n\nAdd to your `Cargo.toml`:\n```toml\n[dependencies]\nlibinfer = \"0.0.3\"\n```\n\n## Usage\nThe goal of the API is to keep as much processing in Rust land as possible. Here is a sample usage:\n\n```rust\nlet options = Options {\n    path: \"yolov8n.engine\".into(),\n    device_index: 0,\n};\nlet mut engine = Engine::new(\u0026options).unwrap();\n\n// Get input dimensions of the engine as [Channels, Height, Width]\nlet dims = engine.get_input_dims();\n\n// Construct a dummy input (uint8 or float32 depending on model)\nlet input_size = dims.iter().fold(1, |acc, \u0026e| acc * e as usize);\nlet input = InputTensor {\n    name: \"input\".to_string();\n    data: vec![0u8; input_size];\n\n// Run inference\nlet output = engine.pin_mut().infer(\u0026input).unwrap();\n\n// Postprocess the output according to your model's output format\n// ...\n```\n\nThis library is intended to be used with pre-built TensorRT engines created by the Python API or the `trtexec` CLI tool for the target device.\n\n## Features\n- Support for both fixed and dynamic batch sizes\n- Automatic handling of different input data types (UINT8, FP32)\n- Direct access to model dimensions and parameters\n- Error handling via Rust's `Result` type\n- Logging integration with `RUST_LOG` environment variable\n\n## Examples\nCheck the `examples/` directory for working examples:\n- `basic.rs`: Simple inference example\n- `benchmark.rs`: Performance benchmarking with various batch sizes\n- `dynamic.rs`: Working with dynamic batch sizes\n- `functional_test.rs`: Testing correctness of model outputs\n\nRun an example with:\n```\ncargo run --example basic -- --path /path/to/model.engine\n```\n\n### Example Requirements\n- You must provide your own TensorRT engine files (.engine)\n- For the functional_test example, you'll need input.bin and features.txt files\n- To create engine files, use NVIDIA's TensorRT tools such as:\n  - TensorRT Python API\n  - trtexec command-line tool\n  - ONNX -\u003e TensorRT conversion tools\n\nSee the documentation in each example file for specific requirements.\n\n## Current Limitations\n- The underlying engine code is not threadsafe (and the Rust binding does not implement `Sync`)\n- Engine instances are `Send` but not `Sync`\n- Input and output data transfers happen on the CPU-GPU boundary\n\n## Future Work\n- Allow passing device pointers and CUDA streams for stream synchronization events\n- Async execution support\n\n## Credits\nMuch of the C++ code is based on the [tensorrt-cpp-api](https://github.com/cyrusbehr/tensorrt-cpp-api) repo.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsaronic-technologies%2Flibinfer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsaronic-technologies%2Flibinfer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsaronic-technologies%2Flibinfer/lists"}