Skip to content

TensorFlow Serving API

David Salek edited this page Nov 15, 2017 · 14 revisions

Install python API

In order to run the client code of TensorFlow Serving, install the python API.

sudo pip install tensorflow-serving-api

The installation will fail with the error below in case you do not have gcc version 4.9.

c++: error: unrecognized command line option ‘-fstack-protector-strong’

This is the way to get version 4.9 of the gcc compiler:

sudo apt-get install gcc-4.9 g++-4.9
sudo update-alternatives --remove-all gcc
sudo update-alternatives --remove-all g++
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.9 1 --slave /usr/bin/g++ g++ /usr/bin/g++-4.9
sudo update-alternatives --config gcc

Query the server

Create the ssh tunnel from Raspberry Pi to the machine on your local network where the server runs.

ssh -nNT -L 9000:localhost:9000 salekd@192.168.2.2

You can check that the tunnel is alive in the following way. On the server side, open the port for listening:

nc -l localhost 9000

Make connection from Raspberry Pi and type something

nc localhost 9000

The text you type here, on Raspberry Pi, will be mirrored on the server side.

Test that TensorFlow Serving works by querying the server from Raspberry Pi:

wget https://github.com/salekd/rpizero_smart_camera/raw/master/camera.JPG
python tensorflow_serving/example/inception_client.py --server=localhost:9000 --image=camera.JPG
Clone this wiki locally