Tensorflow服务和客户端调用失败

时间:2018-12-18 23:01:45

标签: python-3.x docker machine-learning deep-learning tensorflow-serving

有什么地方出错吗,因为我在尝试通过(localhost:8517或10.110.110.13:8517)进行客户端呼叫时遇到连接失败

root@ubuntu-xenial:~/serving# docker run -p 8517:8517 --mount type=bind,source=/root/serving/Ser_Model,target=/models/firstmodel -e MODEL_NAME=firstmodel -t tensorflow/serving
2018-12-18 22:42:54.202137: I tensorflow_serving/model_servers/server.cc:82] Building single TensorFlow model file config:  model_name: firstmodel model_base_path: /models/firstmodel
2018-12-18 22:42:54.203105: I tensorflow_serving/model_servers/server_core.cc:461] Adding/updating models.
2018-12-18 22:42:54.203162: I tensorflow_serving/model_servers/server_core.cc:558]  (Re-)adding model: firstmodel
2018-12-18 22:42:54.305763: I tensorflow_serving/core/basic_manager.cc:739] Successfully reserved resources to load servable {name: firstmodel version: 1}
2018-12-18 22:42:54.305814: I tensorflow_serving/core/loader_harness.cc:66] Approving load for servable version {name: firstmodel version: 1}
2018-12-18 22:42:54.305856: I tensorflow_serving/core/loader_harness.cc:74] Loading servable version {name: firstmodel version: 1}
2018-12-18 22:42:54.305899: I external/org_tensorflow/tensorflow/contrib/session_bundle/bundle_shim.cc:363] Attempting to load native SavedModelBundle in bundle-shim from: /models/firstmodel/1
2018-12-18 22:42:54.306021: I external/org_tensorflow/tensorflow/cc/saved_model/reader.cc:31] Reading SavedModel from: /models/firstmodel/1
2018-12-18 22:42:54.313227: I external/org_tensorflow/tensorflow/cc/saved_model/reader.cc:54] Reading meta graph with tags { serve }
2018-12-18 22:42:54.314376: I external/org_tensorflow/tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2
2018-12-18 22:42:54.341301: I external/org_tensorflow/tensorflow/cc/saved_model/loader.cc:162] Restoring SavedModel bundle.
2018-12-18 22:42:54.354011: I external/org_tensorflow/tensorflow/cc/saved_model/loader.cc:138] Running MainOp with key legacy_init_op on SavedModel bundle.
2018-12-18 22:42:54.354072: I external/org_tensorflow/tensorflow/cc/saved_model/loader.cc:259] SavedModel load for tags { serve }; Status: success. Took 48045 microseconds.
2018-12-18 22:42:54.354116: I tensorflow_serving/servables/tensorflow/saved_model_warmup.cc:83] No warmup data file found at /models/firstmodel/1/assets.extra/tf_serving_warmup_requests
2018-12-18 22:42:54.354305: I tensorflow_serving/core/loader_harness.cc:86] Successfully loaded servable version {name: firstmodel version: 1}
2018-12-18 22:42:54.356224: I tensorflow_serving/model_servers/server.cc:286] Running gRPC ModelServer at 0.0.0.0:8500 ...
[warn] getaddrinfo: address family for nodename not supported
2018-12-18 22:42:54.356982: I tensorflow_serving/model_servers/server.cc:302] Exporting HTTP/REST API at:localhost:8501 ...
[evhttp_server.cc : 237] RAW: Entering the event loop ...

尝试获取模型状态,如下所示:

$ curl http://localhost:8517/v1/models/firstmodel

但是我收到了错误消息curl: (56) Recv failure: Connection reset by peer

您能找出通过docker在我的服务命令中出了什么问题吗?

2 个答案:

答案 0 :(得分:1)

8517是docker容器公开的端口。但是您在容器中的端口8500和8501上启动了tf服务器。如果要使其工作,请将docker cmd更改为docker run -p 8501:8501 xxx,并将请求url更改为localhost:8501/xxx/xxx

答案 1 :(得分:0)

端口的使用(用于GRPC的端口号为8500,用于RESTful API的端口号为8501)很重要,并且Solution的链接

为GRPC客户端服务

docker run -p 8500:8500 --mount type=bind,source=/root/serving/Ser_Model,target=/models/firstmodel -e MODEL_NAME=firstmodel -t tensorflow/serving

服务RESTful API客户端

 docker run -p 8501:8501 --mount type=bind,source=/root/serving/Ser_Model,target=/models/firstmodel -e MODEL_NAME=firstmodel -t tensorflow/serving

您还可以检查RESTful api客户端的状态并进行调用,

curl http://localhost:8501/v1/models/firstmodel

curl -d '{"signature_name":"predict_output","instances":[2.0,9.27]}' -X POST http://10.110.110.13:8501/v1/models/firstmodel:predict