Closed brandondutra closed 7 years ago
gcloud uses some new code (new prediction_lib) which at least doesn't use the bundle_shim stuff.
We need to make sure this happens -- https://github.com/TensorLab/tensorfx/blob/master/src/prediction/_model.py#L55
Is there a way to get saved model to do that?
Tried local prediction with my own local prediction script to go around the tag issue. Got the error below. I think this error will also stop gcloud local prediction from working
code
session, meta_graph = bundle_shim.load_session_bundle_or_saved_model_bundle_from_path(args.model_dir, tags=['SERVING']) signature = _get_signature_from_meta_graph(meta_graph, named_key=args.graph_head)
input_alias_map = {friendly_name: tensor_info_proto.name for (friendly_name, tensor_info_proto) in signature.inputs.items() }
output_alias_map = {friendly_name: tensor_info_proto.name for (friendly_name, tensor_info_proto) in signature.outputs.items() }
aliases, tensor_names = zip(*output_alias_map.items())
print('input_alias_map ' + str(input_alias_map)) print('output_alias_map '+ str(output_alias_map)) print(feed_dict)
result = session.run(fetches=tensor_names, feed_dict=feed_dict)
output
input_alias_map {u'instances': u'input/instances:0'} output_alias_map {u'scores': u'output/scores:0', u'label': u'output/label:0'} ('feed_dict', defaultdict(<type 'list'>, {u'input/instances:0': ['<=50K,25,Private,7,Never-married,Machine-op-inspct,Own-child,Black,Male,0,0.0,40.0,United-States', '<=50K,38,Private,9,Married-civ-spouse,Farming-fishing,Husband,White,Male,0,0.0,50.0,United-States']})) W tensorflow/core/framework/op_kernel.cc:993] Failed precondition: Table not initialized. W tensorflow/core/framework/op_kernel.cc:993] Failed precondition: Table not initialized. W tensorflow/core/framework/op_kernel.cc:993] Failed precondition: Table not initialized. W tensorflow/core/framework/op_kernel.cc:993] Failed precondition: Table not initialized. W tensorflow/core/framework/op_kernel.cc:993] Failed precondition: Table not initialized. W tensorflow/core/framework/op_kernel.cc:993] Failed precondition: Table not initialized. W tensorflow/core/framework/op_kernel.cc:993] Failed precondition: Table not initialized. Traceback (most recent call last): File "local_predict.py", line 134, in
local_predict(args)
File "local_predict.py", line 76, in local_predict
feed_dict=feed_dict)
File "/usr/local/google/home/brandondutra/cml-virtualenv/local/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 767, in run
run_metadata_ptr)
File "/usr/local/google/home/brandondutra/cml-virtualenv/local/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 965, in _run
feed_dict_string, options, run_metadata)
File "/usr/local/google/home/brandondutra/cml-virtualenv/local/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 1015, in _do_run
target_list, options, run_metadata)
File "/usr/local/google/home/brandondutra/cml-virtualenv/local/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 1035, in _do_call
raise type(e)(node_def, op, message)
tensorflow.python.framework.errors_impl.FailedPreconditionError: Table not initialized.
[[Node: input/transform/X/workclass/entries_Lookup = LookupTableFind[Tin=DT_STRING, Tout=DT_INT64, _class=["loc:@input/transform/X/workclass/entries"], _device="/job:localhost/replica:0/task:0/cpu:0"](input/transform/X/workclass/entries, input/parse/workclass, input/transform/X/workclass/entries/Const)]]