aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/go/README.md
diff options
context:
space:
mode:
authorGravatar Asim Shankar <ashankar@google.com>2017-02-07 10:51:02 -0800
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2017-02-07 11:10:58 -0800
commitf2a8620f4e4fcf8f2fdfe8679bf5e2de6d1ae39b (patch)
tree771f509c90b5370b8dcd183b2a0d1846badef1a8 /tensorflow/go/README.md
parent67d5327f1e04dcd97f73ce1cf28ef9cb4d3e6b5e (diff)
Go: Simplify installation.
Utilize the TensorFlow C library release archive to avoid building TensorFlow from source to get going much faster when using Linux/Mac OS X on x86_64. Change: 146805287
Diffstat (limited to 'tensorflow/go/README.md')
-rw-r--r--tensorflow/go/README.md117
1 files changed, 87 insertions, 30 deletions
diff --git a/tensorflow/go/README.md b/tensorflow/go/README.md
index 7696fd4fe4..26e3927afe 100644
--- a/tensorflow/go/README.md
+++ b/tensorflow/go/README.md
@@ -1,4 +1,4 @@
-# TensorFlow Go API
+# TensorFlow in Go
Construct and execute TensorFlow graphs in Go.
@@ -8,39 +8,86 @@ Construct and execute TensorFlow graphs in Go.
> without notice. The same goes for the awkward package path
> (`github.com/tensorflow/tensorflow/tensorflow/go`).
-## Requirements
+## Quickstart
-- Go version 1.7+
-- [bazel](https://www.bazel.build/versions/master/docs/install.html)
-- Environment to build TensorFlow from source code
- ([Linux](https://www.tensorflow.org/versions/master/get_started/os_setup.html#prepare-environment-for-linux)
- or [Mac OS
- X](https://www.tensorflow.org/versions/master/get_started/os_setup.html#prepare-environment-for-mac-os-x)).
- If you'd like to skip reading those details and do not care about GPU
- support, try the following:
+1. Download and extract the TensorFlow C library, preferably into `/usr/local`.
+ GPU-enabled versions require CUDA 8.0 and cuDNN 5.1. For other versions, the
+ TensorFlow C library will have to be built from source (see below).
+
+ - Linux:
+ [CPU-only](https://storage.googleapis.com/tensorflow/libtensorflow/libtensorflow-cpu-linux-x86_64-1.0.0rc1.tar.gz),
+ [GPU-enabled](https://storage.googleapis.com/tensorflow/libtensorflow/libtensorflow-gpu-linux-x86_64-1.0.0rc1.tar.gz)
+ - OS X
+ [CPU-only](https://storage.googleapis.com/tensorflow/libtensorflow/libtensorflow-cpu-darwin-x86_64-1.0.0rc1.tar.gz),
+ [GPU-enabled](https://storage.googleapis.com/tensorflow/libtensorflow/libtensorflow-gpu-darwin-x86_64-1.0.0rc1.tar.gz)
+
+ The following shell snippet downloads and extracts into `/usr/local`:
```sh
- # On Linux
- sudo apt-get install python swig python-numpy
+ TF_TYPE="cpu" # Set to "gpu" for GPU support
+ curl -L \
+ "https://storage.googleapis.com/tensorflow/libtensorflow/libtensorflow-${TF_TYPE}-$(go env GOOS)-x86_64-1.0.0rc1.tar.gz" |
+ sudo tar -C /usr/local -xz
+ ```
- # On Mac OS X with homebrew
- brew install swig
+2. `go get` this package (and run tests):
+
+ ```sh
+ go get github.com/tensorflow/tensorflow/tensorflow/go
+ go test github.com/tensorflow/tensorflow/tensorflow/go
```
-## Installation
+3. Done!
+
+### Installing into locations other than `/usr/local`
+
+The TensorFlow C library (`libtensorflow.so`) needs to be available at build
+time (e.g., `go build`) and run time (`go test` or executing binaries). If the
+library has not been extracted into `/usr/local`, then it needs to be made
+available through the `LIBRARY_PATH` environment variable at build time and the
+`LD_LIBRARY_PATH` environment variable (`DYLD_LIBRARY_PATH` on OS X) at run
+time.
+
+For example, if the TensorFlow C library was extracted into `/dir`, then:
+
+```sh
+export LIBRARY_PATH=/dir/lib
+export LD_LIBRARY_PATH=/dir/lib # For Linux
+export DYLD_LIBRARY_PATH=/dir/lib # For OS X
+```
+
+## Building the TensorFlow C library from source
+
+If the "Quickstart" instructions above do not work (perhaps the release archives
+are not available for your operating system or architecture, or you're using a
+different version of CUDA/cuDNN), then the TensorFlow C library must be built
+from source.
-1. Download the TensorFlow source code:
+### Prerequisites
+
+- [bazel](https://www.bazel.build/versions/master/docs/install.html)
+- Environment to build TensorFlow from source code
+ ([Linux](https://www.tensorflow.org/versions/master/get_started/os_setup.html#prepare-environment-for-linux)
+ or [OS
+ X](https://www.tensorflow.org/versions/master/get_started/os_setup.html#prepare-environment-for-mac-os-x)).
+ If you don't need GPU support, then try the following: `sh # Linux sudo
+ apt-get install python swig python-numpy # OS X with homebrew brew install
+ swig`
+
+### Build
+
+1. Download the source code
```sh
go get -d github.com/tensorflow/tensorflow/tensorflow/go
```
-2. Build the TensorFlow library (`libtensorflow.so`):
+2. Build the TensorFlow C library:
```sh
cd ${GOPATH}/src/github.com/tensorflow/tensorflow
./configure
- bazel build -c opt //tensorflow:libtensorflow.so
+ bazel build --config opt //tensorflow:libtensorflow.so
```
This can take a while (tens of minutes, more if also building for GPU).
@@ -50,24 +97,34 @@ Construct and execute TensorFlow graphs in Go.
a. Copying it to a system location, e.g.,
```sh
- cp ${GOPATH}/src/github.com/tensorflow/tensorflow/bazel-bin/tensorflow/libtensorflow.so /usr/local/lib
+ sudo cp ${GOPATH}/src/github.com/tensorflow/tensorflow/bazel-bin/tensorflow/libtensorflow.so /usr/local/lib
```
OR
- b. Setting the
- `LD_LIBRARY_PATH=${GOPATH}/src/github.com/tensorflow/tensorflow/bazel-bin/tensorflow`
- environment variable (`DYLD_LIBRARY_PATH` on Mac OS X).
+ b. Setting environment variables:
+
+ ```sh
+ export LIBRARY_PATH=${GOPATH}/src/github.com/tensorflow/tensorflow/bazel-bin/tensorflow
+ # Linux
+ export LD_LIBRARY_PATH=${GOPATH}/src/github.com/tensorflow/tensorflow/bazel-bin/tensorflow
+ # OS X
+ export DYLD_LIBRARY_PATH=${GOPATH}/src/github.com/tensorflow/tensorflow/bazel-bin/tensorflow
+ ```
-After this, the `go` tool should be usable as normal. For example:
+4. Build and test:
-```sh
-go test -v github.com/tensorflow/tensorflow/tensorflow/go
-```
+ ```sh
+ go test github.com/tensorflow/tensorflow/tensorflow/go
+ ```
+
+## Support
+
+Use [stackoverflow](http://stackoverflow.com/questions/tagged/tensorflow) and/or
+[Github issues](https://github.com/tensorflow/tensorflow/issues).
## Contributions
-This API has been built on top of the [C
-API](https://www.tensorflow.org/code/tensorflow/c/c_api.h),
-which is intended for building language bindings for TensorFlow functionality.
-However, this is far from complete. Contributions are welcome.
+Contributions are welcome. If making any signification changes, probably best to
+discuss on a [Github issue](https://github.com/tensorflow/tensorflow/issues)
+before investing too much time. Github pull requests are used for contributions.