我正在尝试构建一个使用TensorFlow服务的项目,所以我创建了一个带有WORKSPACE文件的目录my_dir,将服务repo克隆到其中,将我的自定义文件放入my_project目录,在tensorflow_serving中配置tensorflow,从my_dir构建tensorflow服务/服务
bazel build //tensorflow_serving/...
Run Code Online (Sandbox Code Playgroud)
那里的一切都很好,然后我尝试构建一个模仿mnist_export的python文件并将其放在my_dir中并生成一个BUILD文件
py_binary(
name = "export_cnn",
srcs = [
"export_cnn.py",
],
deps = [
"@tf//tensorflow:tensorflow_py",
"@tf_serving//tensorflow_serving/session_bundle:exporter",
],
)
Run Code Online (Sandbox Code Playgroud)
但是,当我跑
bazel build //my_project:export_cnn
Run Code Online (Sandbox Code Playgroud)
我收到以下错误:
ERROR:
.../bazel/_bazel_me/3ef3308a843af155635e839105e8da5c/external/tf/tensorflow/core/BUILD:92:1: null failed: protoc failed: error executing command bazel-out/host/bin/external/tf/google/protobuf/protoc '--cpp_out=bazel-out/local_linux-fastbuild/genfiles/external/tf' -Iexternal/tf -Iexternal/tf/google/protobuf/src ... (remaining 1 argument(s) skipped).
tensorflow/core/framework/step_stats.proto: File not found.
tensorflow/core/framework/device_attributes.proto: File not found.
tensorflow/core/framework/graph.proto: File not found.
tensorflow/core/framework/tensor.proto: File not found.
tensorflow/core/protobuf/config.proto: File not found.
tensorflow/core/protobuf/worker.proto: Import "tensorflow/core/framework/step_stats.proto" was not found or had errors.
tensorflow/core/protobuf/worker.proto: Import "tensorflow/core/framework/device_attributes.proto" was not found or …Run Code Online (Sandbox Code Playgroud) 部署了Tensorflow服务并运行测试用于Inception-V3.工作良好.
现在,想为Inception-V3服务进行批处理.例如,想发送10张图像用于预测而不是一张.
怎么做?要更新哪些文件(inception_saved_model.py或inception_client.py)?那些更新是什么样的?以及如何将图像传递给服务 - 它是作为包含图像的文件夹传递还是如何传递?
欣赏这个问题的一些见解.与此相关的任何代码段都非常有用.
=================================
更新了inception_client.py
# Copyright 2016 Google Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT …Run Code Online (Sandbox Code Playgroud) 我有一个模型,它接受任意长度的数据流并执行分类。我使用 Tensorflow Serving 监听 gRPC 请求并对经过训练的模型执行分类。
\n\nGoogle Cloud Speech API 具有“流式语音识别”功能,该功能在使用 gRPC 请求时可用,该功能“允许您将音频流式传输到 Cloud Speech API,并在音频播放时实时接收语音识别结果流”。处理”。
\n\n我相信这是可能的,因为gRPC 文档中描述了双向流 RPC ,其中“服务器和客户端可以 \xe2\x80\x9cping-pong\xe2\x80\x9d:服务器收到请求,然后发回响应,然后客户端根据响应发送另一个请求,依此类推”。
\n\n所以现在我想知道是否可以使用 Tensorflow Serving 实现类似于 Google Cloud Speech API 流识别的功能。我在 TF Serving 的官方文档中可以找到的关于此的唯一参考资料(除非我错过了一些内容)是在描述未来可能的改进时:“Servable 可以是任何类型和接口,从而实现灵活性和未来的改进,例如:流结果[。 ..]”。
\n\n使用 TF Serving 是否已经可以实现此功能(双向流)?如果是这样,怎么办?如果没有,扩展 TF Serving 以添加此功能的最佳方法是什么?
\npython grpc tensorflow tensorflow-serving google-cloud-speech
我有一个检查点形式的 tensorflow 预训练模型,我打算通过将模型转换为savedmodel表单来部署该模型以供服务。保存模型的大小有点过大。(保存模型中的“variables.data-00000-of-0001”文件超过数百MB。)我在谷歌上搜索了如何减少变量的大小,但找不到好的答案。你能帮我理解如何减少张量流保存模型中变量的大小吗?展示一个简单的例子会很棒。谢谢!
我正在尝试在我的生产服务器中使用以下代码(我想将其扩展到 500 TPS 以上)。当我用许多请求淹没服务器时,我面临以下问题。在 1000 个请求中至少有 1 个请求中,channel.close() 调用需要 10-10.5 秒。我在 Flask 服务器上运行代码。目前,对于每个请求,我都在创建一个频道并关闭它。请帮我解决一下这个。
channel = grpc.insecure_channel(serving_address)
stub = prediction_service_pb2_grpc.PredictionServiceStub(channel)
request = predict_pb2.PredictRequest()
request.model_spec.name = model_name
request.model_spec.signature_name = 'serving_default'
request.inputs['model_2_input'].CopyFrom(
make_tensor_proto_engine(img_array, dtype=1, shape=[1, 224, 224, 3]))
result = stub.Predict(request, 6.0)
channel.close()
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用 tf-serving 来部署我的火炬模型。我已将我的火炬模型导出到 onnx。如何为 tf-serving 生成 pb 模型?
有没有办法通过docker在tf服务中设置日志级别?我看到这些参数,但没有看到任何关于在那里记录的信息
--port=8500 int32 Port to listen on for gRPC API
--grpc_socket_path="" string If non-empty, listen to a UNIX socket for gRPC API on the given path. Can be either relative or absolute path.
--rest_api_port=0 int32 Port to listen on for HTTP/REST API. If set to zero HTTP/REST API will not be exported. This port must be different than the one specified in --port.
--rest_api_num_threads=48 int32 Number of threads for HTTP/REST API processing. If not set, will be auto set based …Run Code Online (Sandbox Code Playgroud) 我先说我对 docker 和 docker-compose 缺乏经验。我正在尝试将我的docker run ...命令转换为 docker-compose.yml文件,但是,我无法找到models.config文件。
我能够使用以下docker run ...命令正确运行 tensorflow 服务 docker 容器:
docker run -t --rm \
tensorflow/serving \
-p 8501:8501 \
-v "$(pwd)/models/:/models/" \
--model_config_file=/models/models.config \
--model_config_file_poll_wait_seconds=60
Run Code Online (Sandbox Code Playgroud)
这按预期工作,models.config文件位于容器中/models/models.config按预期。
tensorflow-serving 页面没有提到任何关于 docker-compose 的内容,但是,我更愿意使用它而不是docker run ...命令。我对 docker-compose 文件的尝试是:
version: '3.3'
services:
server:
image: tensorflow/serving
ports:
- '8501:8501'
volumes:
- './models:/models'
environment:
- 'model_config_file=/models/models.config'
- 'model_config_file_poll_wait_seconds=60'
Run Code Online (Sandbox Code Playgroud)
使用这个 docker-compose 文件,容器运行,但是,环境变量似乎被完全忽略了,所以我不确定我是否应该这样设置它们。容器映像在models.config文件的默认位置查找,但它不存在,因此它不会加载在models.config 中定义的配置。
那么,如何使用 …
我在以下场景中运行:
推理客户端所做的是从 4 个独立的摄像头(每个 1 个)获取图像,并将其传递给 TF-Serving 进行推理,以便了解在视频源上看到的内容。
我之前一直通过直接调用 TensorFlow 在推理客户端 Pod 中单独进行推理,但这在显卡的 RAM 上效果不佳。Tensorflow Serving 最近被引入到组合中,以优化 RAM,因为我们不会将重复的模型加载到显卡。
并且性能看起来并不好,对于 1080p 图像,它看起来像这样:
Direct TF:20ms 用于输入张量创建,70ms 用于推理。TF-Serving:80ms 用于 GRPC 序列化,700-800ms 用于推理。
TF-Serving Pod 是唯一一个可以访问 GPU 的容器,并且它是专门绑定的。其他一切都在 CPU 上运行。
我可以做任何性能调整吗?
我正在运行的模型是来自 TF Model Zoo 的 Faster R-CNN Inception V2。
提前谢谢了!
tensorflow ×9
python ×6
flask ×2
bazel ×1
docker ×1
grpc ×1
grpc-python ×1
kubernetes ×1
logging ×1
onnx ×1