Skip to content
Go to file
PiperOrigin-RevId: 339875033
Change-Id: I46c3d5f23d9656b7d1d8ed27838048763b537bd3
12 contributors

Users who have contributed to this file

@asimshankar @tensorflower-gardener @superryanguo @yongtang @saginadir @philstahlfeld @charlesnicholson @Molkree @marpaia @miguelmota @unly @lamberta
103 lines (71 sloc) 3.35 KB

TensorFlow in Go

Construct and execute TensorFlow graphs in Go.


WARNING: The API defined in this package is not stable and can change without notice. The same goes for the package path: (


Refer to Installing TensorFlow for Go

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 source code

    go get -d
  2. Build the TensorFlow C library:

    cd ${GOPATH}/src/
    bazel build -c opt //

    This can take a while (tens of minutes, more if also building for GPU).

  3. Make and available to the linker. This can be done by either:

    a. Copying it to a system location, e.g.,

    sudo cp ${GOPATH}/src/ /usr/local/lib
    sudo cp ${GOPATH}/src/ /usr/local/lib


    b. Setting environment variables:

    export LIBRARY_PATH=${GOPATH}/src/
    # Linux
    export LD_LIBRARY_PATH=${GOPATH}/src/
    # OS X
    export DYLD_LIBRARY_PATH=${GOPATH}/src/
  4. Build and test:

    go generate
    go test

Generate wrapper functions for ops

Go functions corresponding to TensorFlow operations are generated in op/wrappers.go. To regenerate them:


go generate


Use Stack Overflow and/or GitHub issues.


Contributions are welcome. If making any signification changes, probably best to discuss on a GitHub issue before investing too much time. GitHub pull requests are used for contributions.

You can’t perform that action at this time.