没有Tensorflow服务的GCP中的Tensorflow模型部署 [英] Tensorflow Model Deployment in GCP without Tensorflow Serving

查看:109
本文介绍了没有Tensorflow服务的GCP中的Tensorflow模型部署的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


机器学习模型:基于Tensorflow(1.9版)& Python版本3.6

Machine Learning Model: Tensorflow Based (version 1.9) & Python version 3.6

数据输入:从Bigquery

Data Input: From Bigquery

数据输出:到Bigquery

Data Output: To Bigquery

生产预测频率:每月

我已经开发了一个基于Tensorflow的机器学习模型。我已经在本地对其进行了培训,并希望将其部署在Google Cloud Platform中以进行预测。

I have a developed a Tensorflow based machine learning model. I have trained it locally and want to deploy it in Google Cloud Platform for predictions.

该模型从Google Bigquery读取输入数据,而输出预测则必须在Google Bigquery中编写。在运行模型预测之前,必须运行一些数据准备脚本。目前,我无法在生产中使用BigQuery ML,因为它处于Beta阶段。另外,由于这是一个批处理预测,因此我认为Tensorflow Serving并不是一个不错的选择。

The model reads input data from Google Bigquery and the output predictions has to be written in Google Bigquery. There are some data preparation scripts which has to be run before the model prediction is run. Currently I cannot use BigQuery ML in Production as it is in Beta stage. Additionally as it is a batch prediction I don't think Tensorflow Serving will be a good choice.

我尝试部署的策略:


  1. 使用Google ML Engine进行预测::这种方法可在GCS上创建输出零件文件。这些必须合并并写入Google Bigquery。因此,在这种方法中,我必须启动虚拟机以执行数据准备脚本并将ML Engine输出到Google Bigquery脚本。仅在一个月内运行两个脚本,这会增加24x7的VM成本。

  1. Use Google ML Engine for prediction: This approach creates output part files on GCS. These have to be combined and written to Google Bigquery. So in this approach I have to spin up a VM just to execute the data preparation script and ML Engine output to Google Bigquery script. This adds up to 24x7 cost of VM just for running two scripts in a month.

使用Dataflow来执行数据准备脚本使用Google ML Engine :在Tensorflow版本1.9和python版本3.6中开发模型时,Dataflow使用python 2.7。因此,不能使用这种方法。

Use Dataflow for data preparation script execution along with Google ML Engine: Dataflow uses python 2.7 while the model is developed in Tensorflow version 1.9 and python version 3.6. So this approach cannot be used.

Google App Engine :必须使用完整的Web应用程序开发以用于预测。由于预测是成批的,因此此方法不适合。另外,flask / django必须与代码集成在一起才能使用。

Google App Engine: Using this approach a complete web application has to be developed in order to serve predictions. As the predictions are in batch this approach is not suitable. Additionally flask/django has to be integrated with the code in order to use it.

Google Compute Engine :使用这种方法,VM将仅以每月7天的运行时间和两个脚本的速度运行24x7。

Google Compute Engine: Using this approach the VM would be running 24x7 just for running monthly predictions and running two scripts. The would cause a lot of cost overhead.

我想知道什么是Tensorflow模型的最佳部署方法?有一些预处理和后期处理脚本。

I would like to know what is best deployment approach for Tensorflow models which has some pre and post processing scripts.

推荐答案

关于选项3,Dataflow可以从BigQuery读取数据并将准备好的数据存储在BigQuery中

Regarding the option 3, Dataflow can read from BigQuery and store the prepared data in BigQuery at the end of the job.

然后您可以让Tensorflow使用 BigQueryReader 到BigQuery中的数据。

Then you can have Tensorflow use BigQueryReader to data from BigQuery.

您可以使用的另一个 Datalab ,这是一个笔记本,您可以在其中准备数据,然后将其用于预测。

Another that you can use is Datalab, this is a notebook in which you can prepare your data and then use it for your prediction.

这篇关于没有Tensorflow服务的GCP中的Tensorflow模型部署的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆