nmt icon indicating copy to clipboard operation
nmt copied to clipboard

Export model to tensorflow serving

Open StupidL opened this issue 8 years ago • 10 comments

I recently needs to deploy my model to tensorflow serving, but I do not know how to do that exactly even if I read the documentations of exporting a MNIST model. Here is my problem:

  • How to create a signature_def_map to the SavedModelBuilder? I do not understand what the inputs and outputs should be.

Can you provide an example that export the pre-trained nmt model to tensorflow serving model?

StupidL avatar Dec 29 '17 06:12 StupidL

same issue

luozhouyang avatar Jan 25 '18 07:01 luozhouyang

same issue, can anyone help us?

jacks808 avatar Mar 26 '18 05:03 jacks808

same issue, help would be appreciated

ptamas88 avatar Mar 28 '18 15:03 ptamas88

Now I Can answer this: How to create a signature_def_map to the SavedModelBuilder? I do not understand what the inputs and outputs should be.

But I still face some issue on serving model runtime.

The signature_def_map define the input and output of your serving provide.

If you want to export a model to inference from input to a output, that you should define the signature_def_map to find the inference_model input and output. this code could be found at https://github.com/tensorflow/nmt/blob/master/nmt/model_helper.py#L178. And this function should be modified to add some variable to mark what is input and output.

After this . I can export a model to inference input. but I'll keep get <unk> result.

I still work on it. Anything progress will be update here.

jacks808 avatar Mar 29 '18 00:03 jacks808

@jacks808 Can you share your code?

changdongsheng avatar May 04 '18 08:05 changdongsheng

@changdongsheng @jacks808 @ptamas88 Hey guys, GOOD news! I recently exported the model and serve it in tf serving, and it works well! I made a pull request to this repo. You can check the pull request in pull request#344 export model to tf serving, or you can visit my fork directly: tensorflow/nmt. And if you need a client demo, I can provide it.

luozhouyang avatar May 30 '18 14:05 luozhouyang

Thanks a lot! @luozhouyang

StupidL avatar Jun 04 '18 01:06 StupidL

great, thx @luozhouyang

ArashHosseini avatar Sep 25 '18 09:09 ArashHosseini

@luozhouyang Can you pls update this to the actual NMT branch and add to the README How to use it? Thanks!!!

tuyoisaza avatar Jan 17 '19 04:01 tuyoisaza

@luozhouyang How can I load from exported_model and run inference? I use tf.saved_model.loader.load(), but there's a bug: tensorflow.python.framework.errors_impl.FailedPreconditionError: Attempting to use uninitialized value dynamic_seq2seq/decoder/output_projection/kernel [[{{node dynamic_seq2seq/decoder/output_projection/kernel/_100}} = _SendT=DT_FLOAT, client_terminated=false, recv_device="/job:localhost/replica:0/task:0/device:CPU:0", send_device="/job:localhost/replica:0/task:0/device:GPU:0", send_device_incarnation=1, tensor_name="edge_4_dynamic_seq2seq/decoder/output_projection/kernel", _device="/job:localhost/replica:0/task:0/device:GPU:0"]] [[{{node dynamic_seq2seq/decoder/output_projection/kernel/_101}} = _Recv_start_time=0, client_terminated=false, recv_device="/job:localhost/replica:0/task:0/device:CPU:0", send_device="/job:localhost/replica:0/task:0/device:GPU:0", send_device_incarnation=1, tensor_name="edge_4_dynamic_seq2seq/decoder/output_projection/kernel", tensor_type=DT_FLOAT, _device="/job:localhost/replica:0/task:0/device:CPU:0"]]

Could you solve this problem? Thanks!!!

luckysofia avatar Dec 08 '19 11:12 luckysofia