docker + tensorflow serving + tensorflow-gpu jupyter 部署

1.在此记录下测试步骤,方便以后查询,tensorflow serving可以解决模型生产部署问题,在使用之前先安装docker,参考官方文档安装即可,如果需要使用gpu的话,还得安装nvidia-docker,且tensorflow serving的镜像得是对应cuda的版本,例如tensorflow serving:1.12.0-gpu对应最高的cuda版本是9,cudnn版本为7;

2.docker下拉tensorflow serving镜像,因为使用的tensorflow的版本是1.12.0,所以下拉了对应版本的镜像;

docker pull tensorflow/serving:1.12.0

3.tensorflow serving使用的模型格式是特定的save_model格式,效果如下。

import tensorflow as tf

def save_model():
    v1 = tf.Variable(1, name='v1')
    v2 =tf.Variable(2, name='v2')
    v3 = tf.placeholder(tf.int32, name='input')
    y = tf.multiply(tf.add(v1, v2),v3,name='output')
    with tf.Session() as sess:
        sess.run(tf.global_variables_initializer())
        print(sess.run(y, feed_dict={v3: 3}))
        model_path = './model/saved_model_builder/1/'
        builder = tf.saved_model.builder.SavedModelBuilder(model_path)        
        inputs = {'input': tf.saved_model.utils.build_tensor_info(v3)}
        outputs = {'output': tf.saved_model.utils.build_tensor_info(y)}        
        method_name = tf.saved_model.signature_constants.PREDICT_METHOD_NAME        
        prediction_signature = tf.saved_model.signature_def
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值