发生不可能的错误:grpc status = StatusCode.NOT_FOUND,details =“找不到可用于请求的服务

时间:2018-12-10 01:25:50

标签: tensorflow-serving

我正在尝试提供keras.applications模型。我不是第一次借助tensorflow-server泊坞镜映像来这样做,但是对于尝试使用新发布的模型Nasnet Mobile时为什么我的代码停止工作,我一无所知。我得到的错误是:

  

_Rendezvous:<_的RPC终止,终止于:       状态= StatusCode.NOT_FOUND       详细信息=“找不到可用于请求的服务:最新(最晚)”       debug_error_string =“ {”创建“:” @ 1544402081.202806558“,”描述“:”从同级收到错误“,”文件“:” src / core / lib / surface / call.cc“,” file_line“:1036,” grpc_message “:”找不到可用于请求的服务:最新(最晚)“,” grpc_status“:5}”

我使用标准程序来导出模型

from keras import backend as K

K.set_learning_phase(0) # Deactivate train-only-layers like: batch norm and dropout
print(model.input)
print(model.output)

from tensorflow.python.saved_model import builder as saved_model_builder

export_path = 'export/nasnet/1' # should always end on int (model versioning)
builder = saved_model_builder.SavedModelBuilder(export_path)


from tensorflow.python.saved_model import tag_constants, signature_constants
from tensorflow.python.`enter code here`saved_model.signature_def_utils_impl import predict_signature_def
#from tensorflow.python.saved_model.signature_def_utils_impl import build_signature_def

in_tensors = dict()
out_tensors = dict()

sess =  K.get_session()

in_tensors['input'] = sess.graph.get_tensor_by_name('input_1:0')
out_tensors['predictions'] = sess.graph.get_tensor_by_name('predictions/Softmax:0')

prediction_signature = predict_signature_def(inputs=in_tensors,
                                            outputs=out_tensors)

# export the protobuf and its signatures
builder.add_meta_graph_and_variables(sess=sess,
                                    tags=[tag_constants.SERVING],
                                    signature_def_map={
        signature_constants.DEFAULT_SERVING_SIGNATURE_DEF_KEY:prediction_signature})

builder.save()

显示正常输出:

Tensor("input_1:0", shape=(?, 224, 224, 3), dtype=float32)
Tensor("predictions/Softmax:0", shape=(?, 1000), dtype=float32)


INFO:tensorflow:No assets to save.
INFO:tensorflow:No assets to write.
INFO:tensorflow:SavedModel written to: export/nasnet/1/saved_model.pb

b'export/nasnet/1/saved_model.pb'

根据grpc docs,这种错误甚至都不应该由grpc生成。自然地,我使用以下命令将模型安装到docker容器中:

docker run -d -p 8500:8500 \
    --mount type=bind,source=$(pwd)/export/nasnet/,target=/models/nasnet \
    -e MODEL_NAME=nasnet -e TF_CPP_MIN_VLOG_LEVEL=0 \
    --name nasnet_tfserving \
    -t tensorflow/serving:1.10.0 

容器中仅安装了一个版本为1的模型。什么会导致这种状态代码?泊坞窗日志看起来很正常:

  

docker日志nasnet_tfserving   2018-12-10 23:12:06.902367:I tensorflow_serving / model_servers / main.cc:157]构建单个TensorFlow模型文件配置:model_name:nasnet model_base_path:/ models / nasnet   2018-12-10 23:12:06.904872:我tensorflow_serving / model_servers / server_core.cc:462]添加/更新模型。   2018-12-10 23:12:06.904932:我tensorflow_serving / model_servers / server_core.cc:517​​](重新)添加模型:nasnet   2018-12-10 23:12:07.006261:I tensorflow_serving / core / basic_manager.cc:739]已成功保留资源以加载可服务的{name:nasnet版本:1}   2018-12-10 23:12:07.006484:我tensorflow_serving / core / loader_harness.cc:66]批准适用版本{name:nasnet version:1}的负载   2018-12-10 23:12:07.006539:我tensorflow_serving / core / loader_harness.cc:74]正在加载可服务版本{name:nasnet version:1}   2018-12-10 23:12:07.006621:我external / org_tensorflow / tensorflow / contrib / session_bundle / bundle_shim.cc:360]试图从以下文件中将本地SavedModelBundle加载到bundle-shim中:/ models / nasnet / 1   2018-12-10 23:12:07.006810:我external / org_tensorflow / tensorflow / cc / saved_model / reader.cc:31]从以下位置读取SavedModel:/ models / nasnet / 1   2018-12-10 23:12:07.257410:我external / org_tensorflow / tensorflow / cc / saved_model / reader.cc:54]阅读带有标签的元图{服务}   2018-12-10 23:12:07.557033:I external / org_tensorflow / tensorflow / core / platform / cpu_feature_guard.cc:141]您的CPU支持该TensorFlow二进制文件未编译为使用的指令:FMA   2018-12-10 23:12:08.726888:我external / org_tensorflow / tensorflow / cc / saved_model / loader.cc:113]恢复SavedModel捆绑包。   2018-12-10 23:12:09.814493:我external / org_tensorflow / tensorflow / cc / saved_model / loader.cc:148]在SavedModel捆绑包上运行LegacyInitOp。   2018-12-10 23:12:09.814631:我external / org_tensorflow / tensorflow / cc / saved_model / loader.cc:233] SavedModel加载了标签{serve};现状:成功。花费了2807935微秒。   2018-12-10 23:12:09.814818:I tensorflow_serving / servables / tensorflow / saved_model_warmup.cc:83]在/models/nasnet/1/assets.extra/tf_serving_warmup_requests中找不到预热数据文件   2018-12-10 23:12:09.815253:我tensorflow_serving / core / loader_harness.cc:86]已成功加载可服务版本{name:nasnet version:1}   2018-12-10 23:12:09.823923:我tensorflow_serving / model_servers / main.cc:327]在0.0.0.0:8500上运行ModelServer ...   [警告] getaddrinfo:不支持节点名称的地址族   [evhttp_server.cc:235] RAW:进入事件循环...   2018-12-10 23:12:09.832156:我tensorflow_serving / model_servers / main.cc:337]在以下位置导出HTTP / REST API:localhost:8501 ...

有任何评论吗?

1 个答案:

答案 0 :(得分:0)

似乎您的客户端代码写错了。错误消息为“找不到可用于请求的服务:最新(最晚)”。但是您使用“ nasnet”作为模型名称启动了tf服务器。只需在客户端代码中将“ nasnest”更改为“ nasnet”即可。