我可以在Colab中使用Tensorflow Serving部署多个模型吗?

问题描述

我需要一次使用Tensorflow Serving运行两个模型。 我试图使用相同的rest_api_port运行此命令,但使用不同的model_name来运行此命令,

nohup tensorflow_model_server \
  --rest_api_port=8501 \
  --model_name=model \
  --model_base_path="${MODEL_DIR}" >server.log 2>&1

%%bash --bg 
nohup tensorflow_model_server \
  --rest_api_port=8501 \
  --model_name=model_2 \
  --model_base_path="${MODEL_DIR}" >server.log 2>&1

我已将两个模型保存在一个目录下,作为一个模型的两个版本。我用来保存模型代码

import tempfile
import os

MODEL_DIR = tempfile.gettempdir()
version = 1
export_path = os.path.join(MODEL_DIR,str(version))
print('export_path = {}\n'.format(export_path))
tf.keras.models.save_model(
    model,export_path,overwrite=True,include_optimizer=True,save_format=None,signatures=None,options=None
)

一个模型的版本等于1,第二个模型的版本等于2。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)