Tensorflow服务基本示例

时间:2017-01-18 14:05:01

标签: tensorflow

我正在使用Tensorflow serve_basic示例:

https://tensorflow.github.io/serving/serving_basic

设置

以下:https://tensorflow.github.io/serving/setup#prerequisites

在基于ubuntu:latest的docker容器中,我安装了:

巴泽勒:

echo "deb [arch=amd64] http://storage.googleapis.com/bazel-apt stable jdk1.8" | sudo tee /etc/apt/sources.list.d/bazel.list
curl https://bazel.build/bazel-release.pub.gpg | sudo apt-key
sudo apt-get update && sudo apt-get install bazel
sudo apt-get upgrade bazel

grpcio:

pip install grpcio

所有包裹:

sudo apt-get update && sudo apt-get install -y         build-essential         curl         libcurl3-dev         git         libfreetype6-dev         libpng12-dev         libzmq3-dev         pkg-config         python-dev         python-numpy         python-pip         software-properties-common         swig         zip         zlib1g-dev

tensorflow服务:

git clone --recurse-submodules https://github.com/tensorflow/serving
cd serving
cd tensorflow
./configure
cd ..

我用bazel构建了源代码并且所有测试都成功运行了:

bazel build tensorflow_serving/...
bazel test tensorflow_serving/...

我可以使用以下命令成功导出mnist模型:

bazel-bin/tensorflow_serving/example/mnist_export /tmp/mnist_model

我可以用以下方式为导出的模型提供服务:

bazel-bin/tensorflow_serving/model_servers/tensorflow_model_server --port=9000 --model_name=mnist --model_base_path=/tmp/mnist_model/

问题

当我测试服务器并尝试使用以下命令将客户端连接到模型服务器时

bazel-bin/tensorflow_serving/example/mnist_client --num_tests=1000 --server=localhost:9000

我看到了这个输出:

root@dc3ea7993fa9:~/serving# bazel-bin/tensorflow_serving/example/mnist_client --num_tests=2 --server=localhost:9000
Extracting /tmp/train-images-idx3-ubyte.gz
Extracting /tmp/train-labels-idx1-ubyte.gz
Extracting /tmp/t10k-images-idx3-ubyte.gz
Extracting /tmp/t10k-labels-idx1-ubyte.gz
AbortionError(code=StatusCode.NOT_FOUND, details="FeedInputs: unable to find feed output images")
AbortionError(code=StatusCode.NOT_FOUND, details="FeedInputs: unable to find feed output images")

Inference error rate is: 100.0%

2 个答案:

答案 0 :(得分:1)

“--use_saved_model”模型标志设置为默认值“true”;启动服务器时使用--use_saved_model = false。这应该有效:

<input type="checkbox" [checked]="object.completed" (change)="object.completed = !objected.completed" >

答案 1 :(得分:0)

我在tensorflow github上提到了这一点,解决方法是删除已创建的原始模型。如果您遇到此问题,请运行 rm -rf /tmp/mnist_model 并重建它