Docker Tensorflow-Serving 预测太大

Jan*_*ler 7 docker grpc tensorflow-serving

我正在尝试使用 Docker + tensorflow-serving 为我的模型提供服务。但是,由于使用迭代器(使用
make_initializable_iterator())为模型提供服务的限制,我不得不拆分我的模型。

我正在使用 grpc 与我在 docker 上的模型进行交互。问题是我预测的张量大约是 10MB,序列化了大约 4.1MB。我得到的错误是:

"grpc_message":"Received message larger than max (9830491 vs. 4194304)"
Run Code Online (Sandbox Code Playgroud)

有没有办法将我的预测写到磁盘而不是在 grpc 响应中传输它们?输出文件是一个 32 通道张量,因此在使用 tf.io.write_file 保存到磁盘之前,我无法将其解码为 png。

谢谢!

Pre*_*rem 7

gRPC 中的默认消息长度为 4MB,但我们可以在您的 gRPC 客户端和 Python 中的服务器请求中扩展大小,如下所示。您将无需流式传输即可发送和接收大消息

request = grpc.insecure_channel('localhost:6060', 
options=[('grpc.max_send_message_length', MAX_MESSAGE_LENGTH), 
('grpc.max_receive_message_length', MAX_MESSAGE_LENGTH)])
Run Code Online (Sandbox Code Playgroud)

在 GO lang 中,我们有函数引用 URL

https://godoc.org/google.golang.org/grpc#MaxMsgSize https://godoc.org/google.golang.org/grpc#WithMaxMsgSize