tensorflow

Library Archived

Rust language bindings for TensorFlow.

Checked · Sources

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

From the project README ·

SIG Rust TensorFlow

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, pip and wheel
  • 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.

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.

tensorflow beside the projects that share a topic with it
ProjectDownloadsDependentsStarsLatest releaseRuns on (GPU)Native codeLicense
tensorflow This page Archived

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
mpsgraph-rs Listed Dormant

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
oxidizr App Listed

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
Adoption0 active dependents, 0 new dependents in 365 days1 not measured
Adoption measurements
SignalValueSourceFetchedCounts
Active dependents0crates.io database dumpYes
New dependents (365 days)0crates.io database dumpYes
Peak active dependents4crates.io database dumpYes
Active dependents as a share of the peak0.925crates.io database dumpYes
Binary downloads per releaseNot measuredYes
MaintenanceLatest human commit: 22 months ago3 not measured
Maintenance measurements
SignalValueSourceFetchedCounts
Latest human commit2025-01-12GitHub repositoryYes
Latest release2023-08-15crates.io database dumpYes
First release2016-05-05crates.io database dumpYes
Latest version0.21.0crates.io database dumpYes
Days the oldest outside issue waits for a reply1782GitHub repositoryYes
Maintainer replies over 365 days0GitHub repositoryYes
Repository archivedtrueGitHub 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
Distribution29 releases, 7,617 downloads over 30 days5 not measured
Distribution measurements
SignalValueSourceFetchedCounts
Releases29crates.io database dumpYes
Downloads over 30 days7617crates.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
Repository5,480 stars, 436 forks, 44 contributors, 898 commits. Stars alone never qualify a project.
Repository measurements
SignalValueSourceFetchedCounts
GitHub stars5480GitHub repositoryYes — one part of the repository route
GitHub forks436GitHub repositoryYes — one part of the repository route
Contributors with a GitHub account44GitHub contributorsYes — one part of the repository route
Commits on the default branch898GitHub repositoryNo
Repository's main crate left out of the entrynonecrates.io database dumpYes
Facts that never count
Facts that never count measurements
SignalValueSourceFetchedCounts
LicenseApache-2.0crates.io database dumpNo
Runs on, from listed crates and their direct dependenciesGPU support unknowncrates.io database dumpNo
What shows each backendno dependency or feature matches a backend rowcrates.io database dumpNo
Native code, from listed crates and their dependenciesBinds native code: tensorflow, tensorflow-sys. Build uses a native toolchain: pkg-configcrates.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 directly16crates.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.