Notice: This project is still under active development and not guaranteed to have a stable API. This is especially true because the underlying TensorFlow C API has not yet been stabilized as well.
Since this crate depends on the TensorFlow C API, it needs to be compiled first. This crate will automatically compile TensorFlow for you, but it is also possible to manually install TensorFlow and the crate will pick it up accordingly.
The following dependencies are needed to compile and build this crate (assuming TensorFlow itself should also be compiled transparently):
- Python Dependencies
- 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.
Add this to your
[dependencies] tensorflow = "0.3"
and this to your crate root:
extern crate tensorflow;
cargo build -j 1. Since TensorFlow is built during this process, and
the TensorFlow build is very memory intensive, we recommend using the
flag which tells cargo to use only one task, which in turn tells TensorFlow to
build with only on task. Of course, if you have a lot of RAM, you can use a
To include the especially unstable API (which is currently the
For now, please see the Examples for more details on how to use this binding.
Manual TensorFlow Compilation
If you don't want to build TensorFlow after every
cargo clean or you want to work against
unreleased/unsupported TensorFlow versions, manual compilation is the way to go.
See TensorFlow from source first.
The Python/pip steps are not necessary, but building
Install Bazel, which you may need to do from source.
git clone https://github.com/tensorflow/tensorflow
bazel build --compilation_mode=opt --copt=-march=native --jobs=1 tensorflow:libtensorflow.so
--jobs=1is recommended unless you have a lot of RAM, because TensorFlow's build is very memory intensive.
If this is not possible, add
You may need to run
ldconfig to reset
ld's cache after copying
OSX Note: If you are running on OSX, there is a
Homebrew PR in process which, once merged,
will make it easy to install
libtensorflow wihout hassle. In the meantime, you can take a look at
snipsco/tensorflow-build which provides a homebrew
tap that does essentially the same.
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 modul) 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.)
Developers and users are welcome to join #tensorflow-rust on irc.mozilla.org.
See CONTRIBUTING.md for information 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 welcome. After all, thats what a Request For Comment is for!
This project is licensed under the terms of the Apache 2.0 license.