ctranslate2-rs

Library Listed

Rust bindings for OpenNMT/CTranslate2

Downloads
10,244
Dependents
6
Stars
63
Forks
18
Contributors
9
Commits
490
Latest release
0.10.4 ·

About

From the project README ·

This library provides Rust bindings for OpenNMT/CTranslate2.

Usage

Add this crate to your Cargo.toml with selecting the backends you want to use as the features:

[dependencies]
ct2rs = { version = "0.10.4", features = ["cuda", "dnnl", "mkl"] }

Or you can use platform-specific default features by using the ct2rs-platform crate:

[dependencies]
ct2rs = { version = "0.10.4", package = "ct2rs-platform" }

If you want Whisper model support, you need to enable the whisper feature.

See below for more details about the available features.

Prerequisites

The installation of CMake is required to compile the library.

Additional notes for Windows

Setting the environment variable RUSTFLAGS=-C target-feature=+crt-static might be required.

Features

Backend Futures
  • cuda: Enables CUDA support
  • cudnn: Enables cuDNN support

The above features require setting the CUDA_TOOLKIT_ROOT_DIR environment variable appropriately.

Read the full README
  • mkl: Enables Intel MKL support
  • system-mkl: Enables Intel MKL support using the system-installed MKL library instead of downloading and building it
  • openblas: Enables OpenBLAS support (OpenBLAS needs to be installed manually via vcpkg on Windows)
  • dnnl: Enables oneDNN support
  • ruy: Enables Ruy support
  • accelerate: Enables Apple Accelerate support (macOS only)
  • openmp-runtime-comp: Enables OpenMP runtime support
  • openmp-runtime-intel: Enables OpenMP runtime support for Intel compilers
  • disable-cpu-dispatch: Disables CPU kernel dispatching at runtime (should be set when explicitly targeting an architecture)

Multiple features can be enabled at the same time.

To enable Streaming SIMD Extensions 4.1 (SSE4.1), add the -C target-feature=+sse4.1 flag to RUSTFLAGS environment variable.

By default, the ruy feature is enabled.

If you want to use platform-specific default features, use the ct2rs-platform crate.

GPU-Specific Features
  • flash-attention: Enables Flash Attention
  • tensor-parallel: Enables Tensor Parallelism
  • cuda-dynamic-loading: Enables dynamic loading of CUDA libraries at runtime instead of static linking (requires CUDA >= 11)
  • cuda-small-binary: Reduces binary size by compressing device code
Tokenizer Features
  • sentencepiece: Enables SentencePiece tokenizer support
  • tokenizers: Enables HuggingFace's Tokenizers library support
  • all-tokenizers: Enables both sentencepiece and tokenizers support
Additional Features
  • whisper: Enables Whisper model support
  • hub: Enables HuggingFace Hub integration
  • system: Skip compiling CTranslate2 and use the system's pre-installed shared library instead (requires setting the appropriate environment variables to locate the CTranslate2 shared library)
Platform Specific Features

When ct2rs-platform is used, the following features are automatically selected based on the platform:

  • Windows: openmp-runtime-intel, dnnl, cuda, cudnn, cuda-dynamic-loading, mkl
  • Intel MacOS: dnnl, mkl
  • Apple Silicon MacOS: accelerate, ruy
  • Linux (non-ARM): dnnl, openmp-runtime-comp, cuda, cudnn, cuda-dynamic-loading, mkl, tensor-parallel
  • Linux (ARM): openmp-runtime-comp, openblas, ruy

Supported Models

The ct2rs crate has been tested and confirmed to work with the following models:

  • BART
  • BLOOM
  • FALCON
  • Marian-MT
  • MPT
  • NLLB
  • GPT-2
  • GPT-J
  • OPT
  • T5
  • Whisper

Please see the respective examples for each model.

Stream API

This crate also offers a streaming API that utilizes callback closures. Please refer to the example code for more information.

Model Conversion for CTranslate2

To use model files with CTranslate2, they must first be converted. Below is an example of how to convert the nllb-200-distilled-600M model:

pip install ctranslate2 huggingface_hub torch transformers
ct2-transformers-converter --model facebook/nllb-200-distilled-600M --output_dir nllb-200-distilled-600M \
    --copy_files tokenizer.json

For more details, please refer to the CTranslate2's docs.

Development

When using mise in this repository, sccache is enabled by default for Rust and C/C++ compilation. Run mise install first. CTranslate2 and its dependencies are still built from source; cached compiler outputs can speed up later builds. The first build with an empty cache may be slower.

mise builds use target/sccache to keep their CMake configuration separate from builds without sccache. To run a build without sccache in a POSIX shell, use a separate target directory:

env -u RUSTC_WRAPPER -u CMAKE_C_COMPILER_LAUNCHER -u CMAKE_CXX_COMPILER_LAUNCHER \
  CARGO_TARGET_DIR=target/no-sccache cargo build -p ct2rs --release

Use the same target directory when switching back to cached builds only after reconfiguring CMake; otherwise its cached compiler launcher settings may persist. cargo clean under mise only cleans the active CARGO_TARGET_DIR. These settings are local development defaults and are not required for users of the published crate.

License

This application is released under the MIT License. For details, see the LICENSE file.

CTranslate2 (which this crate builds and links to) is licensed under MIT License. If you redistribute binaries or source that include CTranslate2, you must comply with the MIT terms, including preserving license and notice files. For details, see CTranslate2’s upstream LICENSE/NOTICE.

The published crate may build and/or redistribute artifacts originating from the following third-party projects. Each component remains under its own license, which applies in addition to this crate’s MIT license. When redistributing your software, ensure that you include the required attributions and license texts for any components that were used by your build configuration and target platform. The exact set of components used can depend on enabled features, target architecture, and toolchain.

The published crate also includes the following libraries:

BSD-2-Clause:

BSD-3-Clause:

Apache License 2.0:

MIT License:

Runs on
CUDA
What shows it
  • CUDA: ct2rs feature cuda, ct2rs-platform feature cuda
Native code
Required
  • Binds native code: cxx, link-cplusplus, intel-onemkl-prebuild (feature mkl), onednn-src (feature dnnl), openblas-src (feature openblas) and 1 more
  • Build uses a native toolchain: cmake, cxx-build
Python bindings
No Python binding crate found
License
MIT

Compare with similar projects

Order: strongest tier first, then most downloads, then name, with unmeasured values last. A library counts downloads over 30 days. An app counts binary downloads per release. An app with none counts its crate downloads over 30 days. ML Rust runs this catalogue, so its closest project always gets a row.

ctranslate2-rs beside the projects that share a topic with it
ProjectDownloadsDependentsStarsLatest releaseRuns on (GPU)Native codeLicense
ctranslate2-rs This page Listed

Rust bindings for OpenNMT/CTranslate2

10,244 downloads over 30 days 6 63 0.10.4 CUDA Binds native code: cxx, link-cplusplus, intel-onemkl-prebuild (feature mkl), onednn-src (feature dnnl), openblas-src (feature openblas) and 1 more. Build uses a native toolchain: cmake, cxx-build MIT
ort Featured

A safe Rust wrapper for ONNX Runtime 1.31 - Optimize and accelerate machine learning inference & training

3,902,768 downloads over 30 days 694 2,611 2.0.0-rc.15 CUDA, WebGPU, ROCm Binds native code: onnxruntime, ort-sys. Build uses a native toolchain: pkg-config (feature pkg-config) Apache-2.0 OR MIT
llama-cpp-rs Featured

llama.cpp bindings for Rust

341,382 downloads over 30 days 98 665 0.1.161 CUDA, WebGPU, Metal, ROCm, Vulkan Binds native code: llama. Build uses a native toolchain: bindgen, cc, cmake Apache-2.0 OR MIT
tflite-rs Listed Dormant

Rust bindings for TensorFlow Lite

550 downloads over 30 days 1 129 0.9.8 GPU support unknown Build uses a native toolchain: bindgen Apache-2.0 OR MIT
blazr App Listed

Inference server for LLMs, speech and embeddings: OpenAI-compatible routes with streaming, plus speech synthesis (TTS) and transcription (ASR). Serves Llama, Mistral, Qwen, Mamba2, MLA+MoE and hybrid models from SafeTensors, AWQ, GPTQ and GGUF.

8 binary downloads per release Not applicable 7 0.7.1 CUDA, WebGPU Binds native code: ring (feature distributed) Apache-2.0
oxibonsai Listed

Pure Rust 1-bit LLM inference engine for PrismML Bonsai models — umbrella crate

1 downloads over 30 days 0 137 0.2.3 CUDA, Metal No native code found Apache-2.0
baseRT New

Safe Rust bindings for the BaseRT LLM inference engine (Apple Silicon)

49 downloads over 30 days 2 247 0.4.6 GPU support unknown Binds native code: baseRT, baseRT-sys Apache-2.0
Why ListedNo archive, New or Featured rule places it, so it is Listed.

What it lacks for Featured

  • It has 5 active dependents and 5 new dependents in 365 days. Featured needs 11 active dependents or 9 new dependents in 365 days. The repository route reads 63 stars, 18 forks and 9 contributors. It needs 4,539 stars, 434 forks and 79 contributors together.

What else the check found

  • The last activity is on 3 Nov 2026, 6 days ago. The rules expect an update within 450 days. Dormancy rule

Exact rules: Listed, Featured library. The check on applied thresholds version 9.

Every rule outcome, as the check records it
  • expected-interval: version 0.10.4 base 450: E = 450 days
  • dormancy: last activity 2026-11-03, 6 days ago, E = 450: active
  • featured: not featured: active_users 5 < 11 and new_adopters 5 < 9 and repository route stars 63 (needs 4539), forks 18 (needs 434), contributors 9 (needs 79)
  • listed: listed: no archive, new or featured rule applies
Crates2 crates

Measurements and sources

Each signal row shows the raw value, its source and the fetch date. The Sources list gathers every distinct source on this page. Movement needs more history.

Sources6 sources
Adoption5 active dependents, 5 new dependents in 365 days1 not measured
Adoption measurements
SignalValueSourceFetchedCounts
Active dependents5crates.io database dumpYes
New dependents (365 days)5crates.io database dumpYes
Peak active dependents5crates.io database dumpYes
Active dependents as a share of the peak1crates.io database dumpYes
Binary downloads per releaseNot measuredYes
MaintenanceLatest human commit: 6 days ago3 not measured
Maintenance measurements
SignalValueSourceFetchedCounts
Latest human commit2026-11-03GitHub repositoryYes
Latest release2026-11-03crates.io database dumpYes
First release2024-04-14crates.io database dumpYes
Latest version0.10.4crates.io database dumpYes
Days the oldest outside issue waits for a reply206GitHub repositoryYes
Maintainer replies over 365 days16GitHub repositoryYes
Repository archivedfalseGitHub repositoryYes
Repository gonefalseGitHub repositoryYes
Release commit or manifest in the repotruecrates.io packageYes
Published docstruecrates.io database dumpYes
Latest release fails cargo checkNot measuredYes
Build check dateNot measuredYes
Build check toolchainNot measuredYes
SecurityUnpatched vulnerabilities: none
Security measurements
SignalValueSourceFetchedCounts
Unpatched vulnerabilities past the grace windownoneRustSec advisory databaseYes
RustSec unmaintained advisorynoneRustSec advisory databaseYes
Deprecation noticenonecrates.io database dumpYes
Deprecated requirementnonecrates.io database dumpYes
Distribution44 releases, 10,244 downloads over 30 days5 not measured
Distribution measurements
SignalValueSourceFetchedCounts
Releases44crates.io database dumpYes
Downloads over 30 days10244crates.io database dumpYes
Binary downloads over the last 3 releasesNot measuredYes
Homebrew installs on request over 365 daysNot measuredYes
Repology repository familiesNot measuredYes
Docker pull growth over 90 daysNot measuredYes
Docker pulls at the growth baselineNot measuredYes
Every version a prereleasefalsecrates.io database dumpYes
Every version 0.0.xfalsecrates.io database dumpYes
Every version yankedfalsecrates.io database dumpYes
Crate deleted from crates.iofalsecrates.io database dumpYes
Repository63 stars, 18 forks, 9 contributors, 490 commits. Stars alone never qualify a project.
Repository measurements
SignalValueSourceFetchedCounts
GitHub stars63GitHub repositoryYes — one part of the repository route
GitHub forks18GitHub repositoryYes — one part of the repository route
Contributors with a GitHub account9GitHub contributorsYes — one part of the repository route
Commits on the default branch490GitHub repositoryNo
Repository's main crate left out of the entrynonecrates.io database dumpYes
Facts that never count
Facts that never count measurements
SignalValueSourceFetchedCounts
LicenseMITcrates.io database dumpNo
Runs on, from listed crates and their direct dependenciesCUDAcrates.io database dumpNo
What shows each backendCUDA: ct2rs feature cuda, ct2rs-platform feature cudacrates.io database dumpNo
Native code, from listed crates and their dependenciesBinds native code: cxx, link-cplusplus, intel-onemkl-prebuild (feature mkl), onednn-src (feature dnnl), openblas-src (feature openblas) and 1 more. Build uses a native toolchain: cmake, cxx-buildcrates.io database dumpNo
Python bindings, from direct dependencies of listed cratesNo Python binding crate foundcrates.io database dumpNo
Crates that depend on a listed crate directly6crates.io database dumpNo

Corrections and review history

Report a correction

No correction applies to this entry.

Judgments

A judgment enters only through an approved issue and a merged pull request.

No judgment applies to this entry.