Using TensorFlow with Go | Andrew Whaley's Blog

Security and other geeky stuff.

Using TensorFlow with Go

Tags: ,

Having had some good success using DarkNet Yolo3 object detection, from C, on a Jetson Nano, I wanted to get a bit deeper and understand more about the underlying implementation of deep learning networks. TensorFlow seems the obvious place to start but I really didn’t want to use a horribly inefficient scripting language like Python or JS but C++ looked a bit too ugly and so I thought using Go might be a good compromise being somewhere between C and Python. Also Go is ‘officially’ supported by Tensorflow – or so I thought.

So following the installation guide, it rapidly becomes clear that TensorFlow just doesn’t install and is completely broken for Go (on Ubuntu 19.10 as at January 2020). So then I thought I’d try building from source by following this guide¬†and, again, there are multiple failures. There are basically three issues and here’s how you need to solve them :-

1. The current master branch is broken, you need to check out a the known good commit :-

git clone
git checkout 36ef4264270e3815ea4b485a52e35e26e43e2112

2. There’s an incompatibility with glibc 2.3 (used by Ubuntu) because of a name clash with grpc, so download and install this patch :-

git am Add-grpc-fix-for-gettid.patch

3. Don’t follow the advice in the building from source guide to copy the built libraries to /usr/local/lib this ignores the fact that there are several symlinks and it breaks it. Instead just set LIBRARY_PATH and LD_LIBRARY_PATH to your build directory as also suggested.

Other than these changes follow the rest of the build guide and you should be left with a working TensorFlow in Go. I don’t really understand why Google can’t have tested their Go support and fixed these issues.

Now I’m looking forward to actually doing something with TensorFlow.