ort

pykeioApache-2.0活跃维护

用 Rust 封装 ONNX Runtime,让 ONNX 模型在 Rust 里跑推理和训练都很快,适合需要低延迟、无 Python 依赖的部署场景。

Fast ML inference & training for ONNX models in Rust

v2.0.0-rc.15发布于 2026-10-19 07:26 UTC2,611star +1 / 7 天279fork同步于 2026-11-10 17:45 UTC

怎么上手

由 README 提炼,执行前请确认
cargo add ort
硬件要求按 README 说明

README 未说明具体显存或 GPU 型号要求,仅称支持几乎所有硬件加速器,且轻量到可运行在用户设备上。

下载:源码 zip·GitHub Releases(安装包)本站不镜像安装包

项目说明

由 README 自动翻译提炼

Rust 里跑 ONNX 模型推理和训练,把 PyTorch/TF 模型部署到端侧或数据中心

用 Rust 封装 ONNX Runtime,让 ONNX 模型在 Rust 里跑推理和训练都很快,适合需要低延迟、无 Python 依赖的部署场景。

核心能力

  • 封装微软 ONNX Runtime 做硬件加速推理与训练
  • 支持多种硬件加速器,也能跑在用户设备上
  • 可加载 PyTorch/TensorFlow/Keras/scikit-learn/PaddlePaddle 导出的模型
  • 除 ONNX Runtime 外还支持其他纯 Rust 运行时后端

容易踩的坑

README 未说明依赖版本、模型下载或默认端口等细节,建议查阅官方 Guide 与 Examples

内容由模型根据 README 生成,可能不完整或不准确,以官方文档为准。看原文 README

最近发版

5 个版本v2.0.0-rc.15
  1. v2.0.0-rc.15最新正式版2026-10-19 · 2026-10-19 07:26 UTC

    2.0.0-rc.15

    💖 If you find ort useful, please consider supporting us on Open Collective 💖

    🤔 Need help upgrading? Ask questions in GitHub Discussions or in the pyke.io Discord server!

    ✨ Supporters get priority (<24h) issue resolution & support!


    rc.15 fixes over 30 instances of undefined behavior and adds no new features. It is highly recommended to upgrade to rc.15 as soon as possible, as multiple memory leaks/memory safety issues were fixed.

    Alternative backends will be updated sometime before Oct 23.

    • run_async now only accepts owned inputs.
    • ExecutionProviderLibrary::unregister has been removed. You can still unregister EP libraries via the unsafe -sys API.
    • ValueRefMut no longer implements DerefMut to Value. It has the same methods as &mut Value and can be used in the same places in the ort API. It is recommended to take ValueRefMut anywhere you used to take &mut Value.
    • InMemorySession no longer implements DerefMut to Session. It has the same methods as &mut Session.
    • Kernel now requires Send; ThreadManager requires Send + Sync.
    • SessionBuilder::with_external_initializer_file_in_memory now takes Arc<[u8]> instead of Cow<'static, [u8]>.

  2. v2.0.0-rc.142026-10-12 · 2026-10-12 20:34 UTC
    查看更新说明

    2.0.0-rc.14

    💖 If you find ort useful, please consider supporting us on Open Collective 💖

    🤔 Need help upgrading? Ask questions in GitHub Discussions or in the pyke.io Discord server!

    ✨ Supporters get priority (<24h) issue resolution & support!


    ⚠️ Manual environments

    ort replaced the manual Environment struct with ort::init all the way back in Nov 2023 with 2.0.0-alpha.1 (yes, before rc hell, we used to be in alpha hell). This was done because only one environment was allowed per process anyway. However, almost every other release since then, there has been some kind of issue stemming from the environment being stored as a global variable.

    The trouble caused by this now far outweighs the inconvenience of lugging around another variable everywhere, so in rc.14, you must always first create an Environment to start building sessions:

    // pre-rc.14
    {
        // optional, even!
        ort::init().commit()?;
    
        let mut model = Session::builder()?
            .with_optimization_level(GraphOptimizationLevel::Level3)?
            .with_intra_threads(4)?
            .commit_from_file("yolov8m.onnx")?;
    }
    
    // rc.14
    {
        let env = ort::init().build()?; // <-- must build an environment first
        let mut model = Session::builder(&env)?
            .with_optimization_level(GraphOptimizationLevel::Level3)?
            .with_intra_threads(4)?
            .commit_from_file("yolov8m.onnx")?;
    }
    

    Note that you don't need to hold onto env unless you intend to create more sessions. Please refrain from storing environments or sessions as global variables -- we can't fix the issues that causes within ONNX Runtime! And library authors, please remember to allow the user to pass their own Environment.

    ✨ Rust 1.100 compatibility

    rc.14 adds support for the upcoming v2 build dir layout that will ship in Rust 1.100. If you intend to update to Rust 1.100, you should upgrade to rc.14 as soon as possible, since older ort versions will fail to build when copy-dylibs is enabled.

    Note that, due to the new layout, tests will no longer be able to see dylibs copied by copy-dylibs; you can try to use ort::util::preload_dylib to manually set the path to provider dylibs instead.

    📦 You get a binary! You get a binary! Everyone gets binaries!

    🟩 rc.14's prebuilt CUDA binaries add support for RTX 50xx/Blackwell cards on x64. We now also ship aarch64 builds for Jetson Orin/Thor, Grace Hopper/Blackwell, & DGX Spark! Turing & Ampere GPUs remain fully supported.

    🟥 Team Red gets some love as well: we now have MIGraphX binaries on x64 Linux! In the future, we'll also ship Windows builds with the Vitis AI EP for NPU acceleration on Ryzen AI chips.

    🟦 We didn't forget about Team Blue either! We're also shipping OpenVINO builds for Windows & Linux x64.

    🤖 x64 Android binaries were also added to make simulation easier.

    ⚙️ Miscellaneous features

  3. v2.0.0-rc.132026-07-28 · 2026-07-28 08:13 UTC
    查看更新说明

    2.0.0-rc.13

    💖 If you find ort useful, please consider sponsoring us on Open Collective 💖

    🤔 Need help upgrading? Ask questions in GitHub Discussions or in the pyke.io Discord server!


    🎯 Execution provider clarity

    EP structs like ep::CUDA are now compile-time gated behind their respective Cargo feature flags. The EP feature flags only modifying runtime behavior was a common pain point, and this change brings ort in line with, like, every other Rust crate in existence.

    ⚠️ ort will now throw an error at link time if download-binaries is enabled and no binaries contain all of the requested EPs. Previously, if you enabled a nonsensical combination like cuda + coreml, ort would silently fall back to a CPU-only build. This caused great confusion as the only indicator of what went wrong was in log messages that don't show by default. A new lax-feature-matching Cargo feature will fallback to the closest fit instead of erroring.

    🍎 ONNX Runtime 1.28

    rc.13 skips ahead 4 ONNX Runtime versions to v1.28, bringing new operator support, bug & security fixes, and performance improvements.

    ✖️ No CUDA 12

    rc.13 only ships CUDA 13 binaries, as ONNX Runtime has deprecated CUDA 12.

    🧩 Custom operator ergonomics

    Custom operators have been reworked to have a more Rusty interface:

     struct MyOperator;
     
     impl Operator for MyOperator {
    +	type Kernel<'attr> = ort::operator::BoxedKernel<'attr>;
     
     	fn name(&self) -> &str {
     		"MyOperator"
     	}
     
    -	fn inputs(&self) -> Vec<OperatorInput> {
    -		vec![OperatorInput::required(TensorElementType::Float32), OperatorInput::required(TensorElementType::Float32)]
    +	fn inputs(&self) -> impl IntoIterator<Item = OperatorInput> {
    +		[OperatorInput::required(TensorElementType::Float32), OperatorInput::required(TensorElementType::Float32)]
     	}
     
    -	fn outputs(&self) -> Vec<OperatorOutput> {
    -		vec![OperatorOutput::required(TensorElementType::Float32)]
    +	fn outputs(&self) -> impl IntoIterator<Item = OperatorOutput> {
    +		[OperatorOutput::required(TensorElementType::Float32)]
     	}
     
    -	fn create_kernel(&self, _: &KernelAttributes) -> ort::Result<Box<dyn Kernel>> {
    -		Ok(Box::new(|ctx: &KernelContext| {
    +	fn create_kernel<'attr>(&self, _: &KernelContext<'attr>) -> ort::Result<Self::Kernel<'attr>> {
    +		Ok(Box::new(|ctx: &ComputeContext| {
     			...
     		}))
     	}
     }
    

    ℹ️ Custom diagnostic messages

    ort now uses the wonderful #[diagnostic] attributes to drastically improve the clarity of commonly encountered errors.

    ☑️ Miri-approved

    Test coverage was expanded and ort was ran against Miri, and a few unsoundness bugs were fixed.

    ✨ Other features

    🔧 Other fixes

  4. v2.0.0-rc.122026-03-05 · 2026-03-05 05:41 UTC
    查看更新说明

    2.0.0-rc.12

    💖 If you find ort useful, please consider sponsoring us on Open Collective 💖

    🤔 Need help upgrading? Ask questions in GitHub Discussions or in the pyke.io Discord server!


    This release was made possible by Rime.ai!

    Authentic AI voice models for enterprise.


    📍 Multiversioning

    🚨 If you used ort with default-features = false, enable the api-24 feature to use the latest features.

    The big highlight of this release is multiversioning: ort can now use any minor version of ONNX Runtime from v1.17 to v1.24. New features are gated behind api-* feature flags, like api-20 or api-24. These flags will set the minimum version of ONNX Runtime required by ort.

    More info 👉 https://ort.pyke.io/setup/multiversion

    🪄 Automatic device selection

    With ONNX Runtime 1.22 or later, ort will now automatically use an NPU if one is available for maximum efficiency & power savings! Setting your own execution providers will override this.

    This is thanks to the super cool new SessionBuilder::with_auto_device API! There's also SessionBuilder::with_devices for finer control.

    👁️ CUDA 13

    ort now ships builds for both CUDA 12 & CUDA 13! It should automatically detect which CUDA you're using, but if it gets it wrong, you can override it by setting the ORT_CUDA_VERSION environment variable to 12 or 13.

    🩹 SessionBuilder error recovery

    You can now recover from errors when building a session by calling .recover() on the error type to get the SessionBuilder back.

    🛡️ Build attestations

    Prebuilt binaries are now attested via GitHub Actions, so you can verify that they are untampered builds of ONNX Runtime coming straight from pyke.io.

    To verify, download your binary package of choice and use the gh CLI to verify:

    ➜  gh attestation verify --owner pykeio ./x86_64-pc-windows-msvc+cu13.tar.lzma2
    Loaded digest sha256:e96616510082108be228ad6ea026246a31650b7d446b330c6b9671fcb9ae6267 for file://./x86_64-pc-windows-msvc+cu13.tar.lzma2
    Loaded 1 attestation from GitHub API
    
    The following policy criteria will be enforced:
    - OIDC Issuer must match:................... https://token.actions.githubusercontent.com
    - Source Repository Owner URI must match:... https://github.com/pykeio
    - Predicate type must match:................ https://slsa.dev/provenance/v1
    - Subject Alternative Name must match regex: (?i)^https://github.com/pykeio/
    
    ✓ Verification succeeded!
    
    sha256:e96616510082108be228ad6ea026246a31650b7d446b330c6b9671fcb9ae6267 was attested by:
    REPO                  PREDICATE_TYPE                  WORKFLOW
    pykeio/ort-artifacts  https://slsa.dev/provenance/v1  .github/workflows/build-runner.yml@refs/heads/main
    

    (Also note that the SHA-256 hash lines up with the one defined in dist.txt.)


    Moving stuff around

    • The ORT_LIB_LOCATION environment variable has been renamed to ORT_LIB_PATH.
      • Same with all other env vars ending in _LOCATION.
      • The old names will continue to work, but they won't make it into v2.0.0, so it's a good idea to change them now!
    • Everything that used to be in ort::tensor is now in ort::value, because why have a tensor module if the Tensor<T> type actually comes from the value module?
    • IoBinding and Adapter were moved from their own modules into ort::session. All sub-modules
  5. v2.0.0-rc.112026-01-07 · 2026-01-07 21:40 UTC
    查看更新说明

    💖 If you find ort useful, please consider sponsoring us on Open Collective 💖

    🤔 Need help upgrading? Ask questions in GitHub Discussions or in the pyke.io Discord server!


    I'm sorry it took so long to get to this point, but the next big release of ort should be, finally, 2.0.0 🎉. I know I said that about one of the old alpha releases (if you can even remember those), but I mean it this time! Also, I would really like to not have to do another major release right after, so if you have any concerns about any APIs, please speak now or forever hold your peace!

    A huge thank you to all the individuals who have contributed to the Collective over the years: Marius, Urban Pistek, Phu Tran, Haagen, Yunho Cho, Laco Skokan, Noah, Matouš Kučera, mush42, Thomas, Bartek, Kevin Lacker, & Okabintaro. You guys have made these past rc releases possible.

    If you are a business using ort, please consider sponsoring me. Egress bandwidth from pyke.io has quadrupled in the last 4 months, and 90% of that comes from just a handful of businesses. I'm lucky enough that I don't have to pay for egress right now, but I don't expect that arrangement to last forever. pyke & ort have been funded entirely from my own personal savings for years, and (as I'm sure you're well aware 😂) everything is getting more expensive, so that definitely isn't sustainable.

    Seeing companies that raise tens of millions in funding build large parts of their business on ort, ask for support, and then not give anything back just... seems kind of unfair, no?


    ort-web

    ort-web allows you to use the fully-featured ONNX Runtime on the Web! This time, it's hack-free and thus here to stay (it won't be removed, and then added back, and then removed again like last time!)

    See the crate docs for info on how to port your application to ort-web; there is a little bit of work involved. For a very barebones sample application, see ort-web-sample.

    Documentation for ort-web, like the rest of ort, will improve by the time 2.0.0 comes around. If you ever have any questions, you can always reach out via GitHub Discussions or Discord!

    Features

    • 5d85209 Add WebNN & WASM execution providers for ort-web.
    • #430 (💖 @jhonboy121) Support statically linking to iOS frameworks.
    • #433 (💖 @rMazeiks) Implement more traits for GraphOptimizationLevel.
    • 6727c98 Make PrepackedWeights Send + Sync.
    • 15bd15c Make the TLS backend configurable with new tls-* Cargo features.
    • f3cd995 Allow overriding the cache dir with the ORT_CACHE_DIR environment variable.
    • 🚨 8b3a1ed Load the dylib immediately when using ort::init_from.
      • You can now detect errors from dylib loading and let your program react accordingly.
    • 🚨 #484 (💖 @michael-p) Update ndarray to v0.17.
      • This means you'll need to upgrade your ndarray dependency to v0.17, too.
    • [**`0

用户点评

登录用户的真实使用记录,可按版本和硬件筛选
共 0 条

    还没有人点评。第一个说出真实体验的人最有价值。

    README 原文

    未翻译

    ort is a Rust interface for performing hardware-accelerated inference & training on machine learning models in the Open Neural Network Exchange (ONNX) format.

    Based on the now-inactive onnxruntime-rs crate, ort is primarily a wrapper for Microsoft's ONNX Runtime library, but offers support for other pure-Rust runtimes.

    ort with ONNX Runtime is super quick - and it supports almost any hardware accelerator you can think of. Even still, it's light enough to run on your users' devices.

    When you need to deploy a PyTorch/TensorFlow/Keras/scikit-learn/PaddlePaddle model either on-device or in the datacenter, ort has you covered.

    📖 Documentation

    🤔 Support

    🌠 Backers

    💖 FOSS projects using ort

    Open a PR to add your project here 🌟

    • Text Embeddings Inference (TEI) uses ort to deliver high-performance ONNX Runtime inference for text embedding models.
    • Magika uses ort for neural network-based file type detection.
    • retto uses ort for reliable, fast ONNX inference of PaddleOCR models on Desktop and WASM platforms.
    • edge-transformers uses ort for accelerated transformer model inference at the edge.
    • sbv2-api is a fast implementation of Style-BERT-VITS2 text-to-speech using ort.
    • BoquilaHUB uses ort for local AI deployment in biodiversity conservation efforts.
    • CamTrap Detector uses ort to detect animals, humans and vehicles in trail camera imagery.
    • Ortex uses ort for safe ONNX Runtime bindings in Elixir.
    • oar-ocr A comprehensive OCR library, built in Rust with ort for efficient inference.
    • FastEmbed-rs uses ort for generating vector embeddings, reranking locally.
    • Ahnlich uses ort to power their AI proxy for semantic search applications.
    • nicegal is a desktop image gallery app that uses ort for OCR & semantic image search.
    • Murmure uses ort as its core engine, leveraging NVIDIA Parakeet to deliver fully local, free, private and cross‑platform Speech‑to‑Text enhanced with LLM post‑processing.
    • Valentinus uses ort to provide embedding model inference inside LMDB.
    • SilentKeys uses ort for fast, on-device real-time dictation with NVIDIA Parakeet and Silero VAD.
    • Xybrid uses ort to run LLMs, ASR, and TTS natively on-device across iOS, Android, Flutter, and Unity apps and games.
    • Ultralytics YOLO Rust Inference is a high-performance, pure Rust library and CLI providing a fast and efficient interface for running YOLO models using ort.
    • Air Paint uses ort to run a YOLO hand pose model for real-time air drawing.