我正在尝试构建一个大小小于 1GB 的 TFServing docker 映像。如果您按照在线说明进行操作,您将获得大约 16GB 大小的图像。但是,如果您只构建模型服务器,则可以将大小减小到 3.5GB
bazel build //tensorflow_serving/model_servers:tensorflow_model_server
Run Code Online (Sandbox Code Playgroud)
一半的占用空间来自核心/内核中的动态库构建产品
root@5c275ce482e3:/# du -h -d 1 bazel-out/local-fastbuild/bin/external/org_tensorflow/tensorflow/core/kernels/
780M bazel-out/local-fastbuild/bin/external/org_tensorflow/tensorflow/core/kernels/_objs
1.8G bazel-out/local-fastbuild/bin/external/org_tensorflow/tensorflow/core/kernels/
Run Code Online (Sandbox Code Playgroud)
我认为这可以变得更小,因为 Tensorflow Java API 链接到的 dylib 只有 90MB (GPU)/30MB (CPU)。查看 Bazel BUILD 文件,似乎 JNI/dylib 和 model_servers 目标都依赖于 all_kernels。我不明白为什么 JNI 的 dylib 这么小。如何使 tfserver 构建具有可比较的大小?
我有Tensorflow与python api并获得这些检查点模型文件:
model.ckpt-17763.data-00000-of-00001
model.ckpt-17763.index
model.ckpt-17763.meta
Run Code Online (Sandbox Code Playgroud)
但是在集成到生产环境中时,我想要一个C/C++共享库(.so文件).所以我需要使用C++代码加载这些模型文件和推理并编译到共享库.这样做有一些教程或样本吗?
c++ deep-learning conv-neural-network tensorflow tensorflow-serving
我使用tesnorflow服务构建了一个模型,并使用此命令在服务器上运行它: -
bazel-bin/tensorflow_serving/model_servers/tensorflow_model_server --port=9009 --model_name=ETA_DNN_Regressor --model_base_path=//apps/node-apps/tensorflow-models-repository/ETA
Run Code Online (Sandbox Code Playgroud)
但是现在这个屏幕停滞不前,没有提供任何关于传入请求和共鸣的信息.我尝试使用TF_CPP_MIN_VLOG_LEVEL = 1标志.但现在它提供了如此多的输出,仍然没有记录/监视传入的请求/响应.
请建议如何查看这些日志.
我面临的第二个问题是如何在后台运行此过程并不断监视它.让我们假设我关闭了控制台,然后这个过程也应该运行,以及如何再次重新连接该过程控制台并查看实时流量.
任何建议都会有所帮助.
我目前正在尝试为使用 Tensorflow 的 dnn 预制估计器构建的模型提供 TF 服务。我很高兴看到带有 Tensorflow Serving 1.8 的 Restful API 的发布。
但是,如果我们可以指定包含输入和输出的内容,我看不到如何管理基本身份验证。
预先感谢您的建议。问候。
我正在尝试使用 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。
谢谢!
我最近阅读了本教程。我从教程中获得了训练有素的模型,我想与docker一起使用它,因此我可以向其发送任意字符串,并从模型中获取预测。
我还通读了本教程,以了解如何与Docker一起使用。但是我不理解如何通过接受输入参数来保存模型。例如:
curl -d '{"instances": [1.0, 2.0, 5.0]}' \
-X POST http://localhost:8501/v1/models/half_plus_two:predict
Run Code Online (Sandbox Code Playgroud)
half_plus_two模型如何知道如何处理instances参数?
在文本生成教程中,有一种称为的方法generate_text可以处理生成预测。
def generate_text(model, start_string):
# Evaluation step (generating text using the learned model)
# Number of characters to generate
num_generate = 1000
# Converting our start string to numbers (vectorizing)
input_eval = [char2idx[s] for s in start_string]
input_eval = tf.expand_dims(input_eval, 0)
# Empty string to store our results
text_generated = []
# Low temperatures results in more predictable …Run Code Online (Sandbox Code Playgroud) 我已经部署了一个模型,该模型使用 tfhub 模型来使用 docker 进行 tensorflow 服务。
这是我的模型中包含的 tfhub 模型:
https://tfhub.dev/google/universal-sentence-encoder-multilingual/1
这是运行docker的命令
docker run -t --rm -p 8501:8501 \
-v "/docker_dir/model_tf_serving:/models/mymodel" \
-e MODEL_NAME=mymodel \
tensorflow/serving &
Run Code Online (Sandbox Code Playgroud)
发生错误:
Not found: Op type not registered 'SentencepieceEncodeSparse' in binary running on c5e507bf091b. Make sure the Op and Kernel are registered in the binary running in this process. Note that if you are loading a saved graph which used ops from tf.contrib, accessing (e.g.) `tf.contrib.resampler` should be done before importing the graph, as …Run Code Online (Sandbox Code Playgroud) 我按照TF初学者教程之一的步骤创建了一个简单的分类模型。它们是:
from __future__ import absolute_import, division, print_function, unicode_literals
import numpy as np
import pandas as pd
import tensorflow as tf
from tensorflow import feature_column
from tensorflow.keras import layers
from sklearn.model_selection import train_test_split
URL = 'https://storage.googleapis.com/applied-dl/heart.csv'
dataframe = pd.read_csv(URL)
dataframe.head()
train, test = train_test_split(dataframe, test_size=0.2)
train, val = train_test_split(train, test_size=0.2)
def df_to_dataset(dataframe, shuffle=True, batch_size=32):
dataframe = dataframe.copy()
labels = dataframe.pop('target')
ds = tf.data.Dataset.from_tensor_slices((dict(dataframe), labels))
if shuffle:
ds = ds.shuffle(buffer_size=len(dataframe))
ds = ds.batch(batch_size)
return ds
batch_size = 5 # A …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) tensorflow ×8
python ×3
logging ×2
bash ×1
c++ ×1
docker ×1
grpc ×1
keras ×1
onnx ×1
python-3.6 ×1