Skip to content

Commit ad9af34

Browse files
committed
Refactor README
closes #52
1 parent 48622f2 commit ad9af34

File tree

1 file changed

+66
-50
lines changed

1 file changed

+66
-50
lines changed

README.md

+66-50
Original file line numberDiff line numberDiff line change
@@ -1,90 +1,105 @@
1-
#TensorFlow Rust
1+
# <img alt="TensorFlow" src="https://www.tensorflow.org/images/tf_logo_transp.png" width="170"/> Rust Binding
22
[![Version](https://img.shields.io/crates/v/tensorflow.svg)](https://crates.io/crates/tensorflow)
33
[![Status](https://travis-ci.org/tensorflow/rust.svg?branch=master)](https://travis-ci.org/tensorflow/rust)
44

55
TensorFlow Rust provides idiomatic [Rust](https://www.rust-lang.org) language
66
bindings for [TensorFlow](http://tensorflow.org).
77

8-
This project is still under active development and not guaranteed to have a
9-
stable API. This is especially true because the TensorFlow C API used by this
10-
project has not yet stabilized.
8+
**Notice:** This project is still under active development and not guaranteed to have a
9+
stable API. This is especially true because the underlying TensorFlow C API has not yet
10+
been stabilized as well.
1111

12-
## Using
12+
* [Documentation](https://tensorflow.github.io/rust/tensorflow/)
13+
* [TensorFlow website](http://tensorflow.org)
14+
* [TensorFlow GitHub page](https://github.com/tensorflow/tensorflow)
15+
16+
## Getting Started
17+
Since this crate depends on the TensorFlow C API, it needs to be compiled first. This crate will
18+
automatically compile TensorFlow for you, but it is also possible to manually install TensorFlow
19+
and the crate will pick it up accordingly.
20+
21+
### Prerequisites
22+
The following dependencies are needed to compile and build this crate (assuming TensorFlow itself
23+
should also be compiled transparently):
24+
25+
- git
26+
- [bazel](https://bazel.build/)
27+
- Python Dependencies `numpy`, `dev`, `pip` and `wheel`
28+
- Optionally, CUDA packages to support GPU-based processing
1329

14-
If you only wish to use TensorFlow within your own project, simply include
15-
`tensorflow = "*"` in your `Cargo.toml` file. If the TensorFlow library is
16-
not already installed on your computer in a place it can be found, you will
17-
need the requirements listed in "Automatically Building Tensorflow" below,
18-
and Cargo will build the library for you.
30+
The TensorFlow website provides detailed instructions on how to obtain and install said dependencies,
31+
so if you are unsure please [check out the docs](https://www.tensorflow.org/install/install_sources)
32+
for further details.
1933

20-
## Building
34+
### Usage
35+
Add this to your `Cargo.toml`:
2136

22-
If you only intend to use TensorFlow from within Rust, then you don't need to
23-
build TensorFlow manually and can follow the automatic steps. If you do need to
24-
use TensorFlow outside of Rust, the manual steps will provide you with a
25-
TensorFlow header file and shared library that can be used by other languages.
37+
```toml
38+
[dependencies]
39+
tensorflow = "0.3"
40+
```
2641

27-
### Automatically building TensorFlow
42+
and this to your crate root:
43+
44+
```rust
45+
extern crate tensorflow;
46+
```
2847

29-
Install [SWIG](http://www.swig.org) and [NumPy](http://www.numpy.org). The
30-
version from your distro's package manager should be fine for these two. Also
31-
install [Bazel](http://bazel.io/docs/install.html), which you may need to do
32-
from source.
3348
Then run `cargo build -j 1`. Since TensorFlow is built during this process, and
3449
the TensorFlow build is very memory intensive, we recommend using the `-j 1`
3550
flag which tells cargo to use only one task, which in turn tells TensorFlow to
3651
build with only on task. Of course, if you have a lot of RAM, you can use a
3752
higher value.
53+
3854
To include the especially unstable API (which is currently the `expr` module),
3955
use `--features tensorflow_unstable`.
4056

41-
### Manually building TensorFlow
57+
For now, please see the [Examples](https://github.com/tensorflow/rust/tree/master/examples) for more
58+
details on how to use this binding.
4259

43-
Install [TensorFlow from source](https://www.tensorflow.org/versions/master/get_started/os_setup.html#source).
60+
## Manual TensorFlow Compilation
61+
If you don't want to build TensorFlow after every `cargo clean` or you want to work against
62+
unreleased/unsupported TensorFlow versions, manual compilation is the way to go.
63+
64+
See [TensorFlow from source](https://www.tensorflow.org/install/install_sources) first.
4465
The Python/pip steps are not necessary, but building `tensorflow:libtensorflow.so` is.
4566

4667
In short:
4768

4869
1. Install [SWIG](http://www.swig.org) and [NumPy](http://www.numpy.org). The
4970
version from your distro's package manager should be fine for these two.
50-
1. [Install Bazel](http://bazel.io/docs/install.html), which you may need to do
71+
2. [Install Bazel](http://bazel.io/docs/install.html), which you may need to do
5172
from source.
52-
1. `git clone --recurse-submodules https://github.com/tensorflow/tensorflow`
53-
1. `cd tensorflow`
54-
1. `./configure`
55-
1. `bazel build -c opt --jobs=1 tensorflow:libtensorflow.so`
73+
3. `git clone https://github.com/tensorflow/tensorflow`
74+
4. `cd tensorflow`
75+
5. `./configure`
76+
6. `bazel build --compilation_mode=opt --copt=-march=native --jobs=1 tensorflow:libtensorflow.so`
5677

57-
Using --jobs=1 is recommended unless you have a lot of RAM, because
78+
Using `--jobs=1` is recommended unless you have a lot of RAM, because
5879
TensorFlow's build is very memory intensive.
5980

60-
Copy $TENSORFLOW_SRC/bazel-bin/tensorflow/libtensorflow.so to /usr/local/lib.
61-
If this is not possible, add $TENSORFLOW_SRC/bazel-bin/tensorflow to
62-
LD_LIBRARY_PATH.
81+
Copy `$TENSORFLOW_SRC/bazel-bin/tensorflow/libtensorflow.so` to `/usr/local/lib`.
82+
If this is not possible, add `$TENSORFLOW_SRC/bazel-bin/tensorflow` to
83+
`LD_LIBRARY_PATH`.
6384

64-
You may need to run `ldconfig` to reset `ld`'s cache after copying libtensorflow.so.
85+
You may need to run `ldconfig` to reset `ld`'s cache after copying `libtensorflow.so`.
6586

66-
Now run `cargo build` as usual.
67-
To include the especially unstable API (which is currently the `expr` module),
68-
use `--features tensorflow_unstable`.
69-
70-
## RFCs
71-
RFCs are [issues tagged with RFC](https://github.com/tensorflow/rust/labels/rfc).
72-
Check them out and comment. Discussions are welcome. After all, thats what a Request For Comment is for!
87+
**OSX Note**: If you are running on OSX, there is a
88+
[Homebrew PR](https://github.com/Homebrew/homebrew-core/pull/10273) in process which, once merged,
89+
will make it easy to install `libtensorflow` wihout hassle. In the meantime, you can take a look at
90+
[snipsco/tensorflow-build](https://github.com/snipsco/tensorflow-build) which provides a homebrew
91+
tap that does essentially the same.
7392

74-
## FAQs
93+
## FAQ's
7594

76-
#### Why does the compiler say that parts of the API don't exist?
95+
### Why does the compiler say that parts of the API don't exist?
7796
The especially unstable parts of the API (which is currently the `expr` modul) are
7897
feature-gated behind the feature `tensorflow_unstable` to prevent accidental
7998
use. See http://doc.crates.io/manifest.html#the-features-section.
8099
(We would prefer using an `#[unstable]` attribute, but that
81100
[doesn't exist](https://github.com/rust-lang/rfcs/issues/1491) yet.)
82101

83-
## Other
84-
85-
This project is not directly affiliated with the TensorFlow project, although we
86-
do intend to communicate and cooperate with them.
87-
102+
## Contributing
88103
Developers and users are welcome to join
89104
[#tensorflow-rust](http://chat.mibbit.com/?server=irc.mozilla.org&channel=%23tensorflow-rust)
90105
on irc.mozilla.org.
@@ -93,8 +108,9 @@ See [CONTRIBUTING.md](CONTRIBUTING.md) for information on how to contribute code
93108

94109
This is not an official Google product.
95110

96-
##For more information
111+
RFCs are [issues tagged with RFC](https://github.com/tensorflow/rust/labels/rfc).
112+
Check them out and comment. Discussions are welcome. After all, thats what a Request For
113+
Comment is for!
97114

98-
* [API docs](https://tensorflow.github.io/rust)
99-
* [TensorFlow website](http://tensorflow.org)
100-
* [TensorFlow GitHub page](https://github.com/tensorflow/tensorflow)
115+
## License
116+
This project is licensed under the terms of the [Apache 2.0 license](https://github.com/tensorflow/rust/blob/master/LICENSE).

0 commit comments

Comments
 (0)