tensorflow
Library Archived
Rust language bindings for TensorFlow.
- Downloads
- 7,617
- Dependents
- 16
- Stars
- 5,480
- Forks
- 436
- Contributors
- 44
- Commits
- 898
- Latest release
- 0.21.0 ·
Why Archived
GitHub reports the repository as archived.
Exact rules: Instant archive. The check on applied thresholds version 9.
Every rule outcome, as the check records it
instant-archive: repository is archived
About
TensorFlow Rust provides idiomatic Rust language bindings for TensorFlow.
Notice: This project is still under active development and not guaranteed to have a stable API.
Getting Started
Since this crate depends on the TensorFlow C API, it needs to be downloaded or compiled first. This crate will automatically download or compile the TensorFlow shared libraries for you, but it is also possible to manually install TensorFlow and the crate will pick it up accordingly.
Prerequisites
If the TensorFlow shared libraries can already be found on your system, they will be used. If your system is x86-64 Linux or Mac, a prebuilt binary will be downloaded, and no special prerequisites are needed.
Otherwise, the following dependencies are needed to compile and build this crate, which involves compiling TensorFlow itself:
- git
- bazel
- Python Dependencies
numpy,dev,pipandwheel - Optionally, CUDA packages to support GPU-based processing
The TensorFlow website provides detailed instructions on how to obtain and install said dependencies, so if you are unsure please check out the docs for further details.
Read the full README
Some of the examples use TensorFlow code written in Python and require a full TensorFlow installation.
The minimum supported Rust version is 1.58.
Usage
Add this to your Cargo.toml:
[dependencies]
tensorflow = "0.21.0"
and this to your crate root:
extern crate tensorflow;
Then run cargo build -j 1. The tensorflow-sys crate's
build.rs
now either downloads a pre-built, basic CPU only binary
(the default)
or compiles TensorFlow if forced to by an environment variable. If TensorFlow
is compiled during this process, since the full compilation is very memory
intensive, we recommend using the -j 1 flag which tells cargo to use only one
task, which in turn tells TensorFlow to build with only one task. Though, if
you have a lot of RAM, you can obviously use a higher value.
To include the especially unstable API (which is currently the expr module),
use --features tensorflow_unstable.
For now, please see the Examples for more details on how to use this binding.
Tensor Max Display
When printing or debugging a tensor, it will print every element by default, this can be modified by changing an environment variable:
TF_RUST_DISPLAY_MAX=5
Which will truncate the values if they exceed the limit:
let values: Vec<u64> = (0..100000).collect();
let t = Tensor::new(&[2, 50000]).with_values(&values).unwrap();
dbg!(t);
t = Tensor<u64> {
values: [
[0, 1, 2, 3, 4, ...],
...
],
dtype: uint64,
shape: [2, 50000]
}
GPU Support
To enable GPU support, use the tensorflow_gpu feature in your Cargo.toml:
[dependencies]
tensorflow = { version = "0.21.0", features = ["tensorflow_gpu"] }
Manual TensorFlow Compilation
If you want to work against unreleased/unsupported TensorFlow versions or use a build optimized for your machine, manual compilation is the way to go.
See tensorflow-sys/README.md for details.
FAQ's
Why does the compiler say that parts of the API don't exist?
The especially unstable parts of the API (which is currently the expr module) are
feature-gated behind the feature tensorflow_unstable to prevent accidental
use. See http://doc.crates.io/manifest.html#the-features-section.
(We would prefer using an #[unstable] attribute, but that
doesn't exist yet.)
How do I...?
Try the documentation first, and see if it answers your question. If not, take a look at the examples folder. Note that there may not be an example for your exact question, but it may be answered by an example demonstrating something else.
If none of the above help, you can ask your question on TensorFlow Rust Google Group.
Contributing
Developers and users are welcome to join the TensorFlow Rust Google Group.
Please read the contribution guidelines on how to contribute code.
This is not an official Google product.
RFCs are issues tagged with RFC. Check them out and comment. Discussions are welcomed. After all, that is the purpose of Request For Comment!
License
This project is licensed under the terms of the Apache 2.0 license.
Compatibility
- Runs on
- GPU support unknown
What shows it
- no dependency or feature matches a backend row
- Native code
- Required
- Binds native code: tensorflow, tensorflow-sys
- Build uses a native toolchain: pkg-config
- Python bindings
- No Python binding crate found
- License
- Apache-2.0
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.
| Project | Downloads | Dependents | Stars | Latest release | Runs on (GPU) | Native code | License |
|---|---|---|---|---|---|---|---|
|
Rust language bindings for TensorFlow. |
7,617 downloads over 30 days | 16 | 5,480 | 0.21.0 | GPU support unknown | Binds native code: tensorflow, tensorflow-sys. Build uses a native toolchain: pkg-config | Apache-2.0 |
|
tch-rs Featured
Rust wrappers for the PyTorch C++ api (libtorch). Python bindings |
1,190,464 downloads over 30 days | 124 | 5,518 | 0.26.0 | CUDA | Binds native code: tch, torch-sys. Build uses a native toolchain: cc | Apache-2.0 OR MIT |
|
mlx-rs Featured
Unofficial rust wrapper for Apple's mlx machine learning library. |
33,398 downloads over 30 days | 36 | 389 | 0.34.0 | Metal | Binds native code: mach-sys, mlx, mlx-sys. Build uses a native toolchain: bindgen, cc, cmake | Apache-2.0 OR MIT |
|
aprender Listed
Next-generation ML framework in pure Rust — `cargo install aprender` for the `apr` CLI |
15,442 downloads over 30 days | 31 | 140 | 0.72.3 | CUDA, WebGPU | Binds native code: libsqlite3-sys, zstd-sys, tree-sitter (feature full), alsa-sys (feature audio-alsa), nvml-wrapper-sys (feature nvml) and 1 more. Build uses a native toolchain: bindgen (feature bindgen) | MIT |
|
xla-rs Listed
Bindings for the XLA C++ library. |
864 downloads over 30 days | 2 | 117 | 0.5.4 | GPU support unknown | Build uses a native toolchain: bindgen, cc | Apache-2.0 OR MIT |
|
Modern Rust bindings for Apple's Metal Performance Shaders Graph framework |
398 downloads over 30 days | 2 | Not measured | 0.2.0 | Metal | No native code found | MIT |
|
Trains GPT-style language models from a YAML config and a tokenized dataset: dense GQA transformers, Mamba 1, 2 and 3, MLA and MoE layers on CPU or CUDA. Runs the training loop, optimizer, checkpoints, evaluation and metrics on boostr, and builds speech corpora through voxr. |
27 downloads over 30 days | Not applicable | 8 | 0.1.1 | CUDA | Binds native code: nvml-wrapper-sys (feature cuda) | Apache-2.0 |
Crates4 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
- Description: the crates.io description
- crates.io database dump, fetched
- RustSec advisory database, fetched
- GitHub repository, fetched
- crates.io package, fetched
- GitHub contributors, fetched
Adoption0 active dependents, 0 new dependents in 365 days1 not measured
| Signal | Value | Source | Fetched | Counts |
|---|---|---|---|---|
| Active dependents | 0 | crates.io database dump | Yes | |
| New dependents (365 days) | 0 | crates.io database dump | Yes | |
| Peak active dependents | 4 | crates.io database dump | Yes | |
| Active dependents as a share of the peak | 0.925 | crates.io database dump | Yes | |
| Binary downloads per release | Not measured | Yes |
MaintenanceLatest human commit: 22 months ago3 not measured
| Signal | Value | Source | Fetched | Counts |
|---|---|---|---|---|
| Latest human commit | 2025-01-12 | GitHub repository | Yes | |
| Latest release | 2023-08-15 | crates.io database dump | Yes | |
| First release | 2016-05-05 | crates.io database dump | Yes | |
| Latest version | 0.21.0 | crates.io database dump | Yes | |
| Days the oldest outside issue waits for a reply | 1782 | GitHub repository | Yes | |
| Maintainer replies over 365 days | 0 | GitHub repository | Yes | |
| Repository archived | true | GitHub repository | Yes | |
| Repository gone | false | GitHub repository | Yes | |
| Release commit or manifest in the repo | true | crates.io package | Yes | |
| Published docs | true | crates.io database dump | Yes | |
| Latest release fails cargo check | Not measured | Yes | ||
| Build check date | Not measured | Yes | ||
| Build check toolchain | Not measured | Yes |
SecurityUnpatched vulnerabilities: none
| Signal | Value | Source | Fetched | Counts |
|---|---|---|---|---|
| Unpatched vulnerabilities past the grace window | none | RustSec advisory database | Yes | |
| RustSec unmaintained advisory | none | RustSec advisory database | Yes | |
| Deprecation notice | none | crates.io database dump | Yes | |
| Deprecated requirement | none | crates.io database dump | Yes |
Distribution29 releases, 7,617 downloads over 30 days5 not measured
| Signal | Value | Source | Fetched | Counts |
|---|---|---|---|---|
| Releases | 29 | crates.io database dump | Yes | |
| Downloads over 30 days | 7617 | crates.io database dump | Yes | |
| Binary downloads over the last 3 releases | Not measured | Yes | ||
| Homebrew installs on request over 365 days | Not measured | Yes | ||
| Repology repository families | Not measured | Yes | ||
| Docker pull growth over 90 days | Not measured | Yes | ||
| Docker pulls at the growth baseline | Not measured | Yes | ||
| Every version a prerelease | false | crates.io database dump | Yes | |
| Every version 0.0.x | false | crates.io database dump | Yes | |
| Every version yanked | false | crates.io database dump | Yes | |
| Crate deleted from crates.io | false | crates.io database dump | Yes |
Repository5,480 stars, 436 forks, 44 contributors, 898 commits. Stars alone never qualify a project.
| Signal | Value | Source | Fetched | Counts |
|---|---|---|---|---|
| GitHub stars | 5480 | GitHub repository | Yes — one part of the repository route | |
| GitHub forks | 436 | GitHub repository | Yes — one part of the repository route | |
| Contributors with a GitHub account | 44 | GitHub contributors | Yes — one part of the repository route | |
| Commits on the default branch | 898 | GitHub repository | No | |
| Repository's main crate left out of the entry | none | crates.io database dump | Yes |
Facts that never count
| Signal | Value | Source | Fetched | Counts |
|---|---|---|---|---|
| License | Apache-2.0 | crates.io database dump | No | |
| Runs on, from listed crates and their direct dependencies | GPU support unknown | crates.io database dump | No | |
| What shows each backend | no dependency or feature matches a backend row | crates.io database dump | No | |
| Native code, from listed crates and their dependencies | Binds native code: tensorflow, tensorflow-sys. Build uses a native toolchain: pkg-config | crates.io database dump | No | |
| Python bindings, from direct dependencies of listed crates | No Python binding crate found | crates.io database dump | No | |
| Crates that depend on a listed crate directly | 16 | crates.io database dump | No |
Corrections and review history
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.
