tensorflow-serving部署

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/liaynling/article/details/86607822

一、hadoop集群部署

OS: centos7

1.hadoop3.0集群部署并启动yarn

省略

2.创建python虚拟环境

#安装virtualenv

pip install virtualenv

#创建虚拟环境

cd /data/venv

virtualenv hdp-env

#准备要安装的tensorflow包名及版本号

cat requirement.txt |grep ten

tensorboard==1.12.2

tensorflow==1.12.0

tensorflow-serving-api==1.12.0

tensorflow-tensorboard==1.5.1

#安装python包

./hdp-env/bin/pip2.7 install -r requirement.txt --compile --index-url http://pypi.test-inc.com/youzan/dev/+simple --trusted-host pypi.test-inc.com

#要开始使用虚拟环境,其需要被激活

source venv/bin/activate

#在虚拟环境中暂时完成了工作,则可以停用它

. venv/bin/deactivate

二、tensorflow-serving部署

OS: centos7

1. 部署docker

#安装软件包: docker-1.13.1

sudo yum install docker

#修改配置,改变docker镜像文件路径为/data/docker,镜像下载地址改为公司下载源地址。

vim /etc/sysconfig/docker

OPTIONS='--selinux-enabled --log-driver=journald --signature-verification=false --insecure-registry=abc.s.test-inc.com -g /data/docker'

#docker启动

sudo systemctl  start docker

2.制作tensorflow-serving docker镜像源

#在测试环境下载docker镜像

docker pull tensorflow/serving:1.12.0

#将docker镜像上传到公司测试环境docker镜像源

docker tag tensorflow/serving:1.12.0 abc.test-inc.com/container/tensorflow/serving:1.12.0

docker login abc.test-inc.com

docker push abc.test-inc.com/container/tensorflow/serving:1.12.0

#找王波将测试环境的镜像源上传到生产环境的镜像源才能使用

3.部署tensorflow-serving

#从公司生产环境镜像源下载docker镜像

docker pull abc.s.test-inc.com/container/tensorflow/serving:1.12.0

#下载serving源码,docker镜像运行的时候,需要使用里面的模型文件进行测试

git clone -b r1.12 --recurse-submodules https://github.com/tensorflow/serving

#启动tensorflow-serving

/usr/bin/docker run -it -p 8501:8501  -v "/opt/tensorflow-serving/serving/tensorflow_serving/servables/tensorflow/testdata/saved_model_half_plus_two_cpu:/models/half_plus_two" -e MODEL_NAME=half_plus_two -d abc.s.test-inc.com/container/tensorflow/serving:1.12.0

#测试模型

/usr/bin/curl -d '{"instances": [1.0, 2.0, 5.0]}' -X POST http://localhost:8501/v1/models/half_plus_two:predict

猜你喜欢

转载自blog.csdn.net/liaynling/article/details/86607822