Go Go Tensorflow

Sun, Oct 14, 2018

Fix your Xcode

Do all your system upgrades: I was on High Sierra and needed to upgrade the OS to 10.13.6 so had to install Xcode 10 to get the Command Line Tools

sudo trash /Library/Developer/CommandLineTools
xcode-select --install

After typing ‘accept’ you should be good to move forward

Install Bazel

Have to do

brew tap bazelbuild/tap
brew tap-pin bazelbuild/tap
brew install bazel

Lets check we are running a recent version

bazel version

0.17.2-homebrew should be good

Install SWIG

This one should be easy.

brew install swig

Download and build Tensorflow library

go get -d github.com/tensorflow/tensorflow/tensorflow/go
cd ${GOPATH}/src/github.com/tensorflow/tensorflow
./configure

So I picked a python path that pointed to my which python3 which I installed via the pkg (3.6.x) available at python.org and said no to everything else.

bazel build -c opt //tensorflow:libtensorflow.so

Okay so if your system isn’t perfectly configured…you will get some errors…once you correct a step you missed above (or I missed) run bazel clean --expunge to freshen up the build environment.

sudo cp ${GOPATH}/src/github.com/tensorflow/tensorflow/bazel-bin/tensorflow/libtensorflow*.so /usr/local/lib

Testing

export LD_LIBRARY_PATH=/usr/local/lib
export DYLD_LIBRARY_PATH=/usr/local/lib
go test -v github.com/tensorflow/tensorflow/tensorflow/go

References:

https://docs.bazel.build/versions/master/install-os-x.html https://github.com/tensorflow/tensorflow/blob/master/tensorflow/go/README.md