本文由 发布,转载请注明出处,如有问题请联系我们! 发布时间: 2021-08-01tensorflow安装教程-详解tensorflow基础知识
加载中1.根据docker安装TF-service。
参照文档:
https://tensorflow.Google.cn/tfx/serving/docker
https://zhuanlan.zhihu.com/p/45109194
根据Docker的组装必须先安裝docker。
docker中的下载链接。
https://download.docker.com/linux/ubuntu/dists/
在中国寻找相匹配版本号的ubuntu。
参照ubuntu版本号:
cat /proc/version查看详细信息内容:
lsb_release -a能够见到ubuntu的编码名是xenial,cput是AMD64,因此转到文件夹名称选择文件相匹配的版本号:
获得.deb安装文档:去拿。deb安装文档:
wget https://download.docker.com/linux/ubuntu/dists/xenial/pool/stable/amd64/docker-ce_18.03.0~ce-0~ubuntu_amd64.deb应用dpkg指令安裝:
dpkg -I docker-ce_18.03.0~ce-0~ubuntu_amd64.deb实行hello-world检测,查询安裝是不是取得成功:
用dpkg指令安裝后,碰到docker不可以正常的运行的难题。好像mkl不见了或是systemstl沒有运行docker,忘掉纪录了。之后有朋友发生了,再加上来到。在docker中运行服务项目。
提前准备码头工人自然环境。
docker pull tensorflow/serving该指令将得到一个预组装的虚拟器,能够在docker中实际操作。TensorflowServing给予二种通话:RestFull和GRPC。
I. RestFull API启用。
免费下载tfserving的例子编码。
mkdir tfservingcd tfservinggit clone https://GitHub.com/tensorflow/serving运作TF服务项目。
docker run -p 8501:8501 --mount type=bind,source=/root/maoyaozong/tfserving/serving/tensorflow_serving/servables/tensorflow/testdata/saved_model_half_plus_two_cpu,target=/models/half_plus_two -eMODEL_NAME=half_plus_two-ttensorflow/serving这儿给予端口号8501做为REST API的端口,关联到模具的初始详细地址,取名为model_name=half_plus_two。
手机客户端身份认证
curl -d'{"instances": [1.0, 2.0, 5.0]}' -X POST http://localhost:8501/v1/models/half_plus_two:predict获得回到結果。
{ "predictions": [2.5, 3.0, 4.5] }第二,GRPC API启用。
免费下载tfserving的例子编码。
mkdir tfservingcd tfservinggit clone https://github.com/tensorflow/serving实体模型编译程序
/root/anaconda3/bin/pythontensorflow_serving/example/mnist_saved_model.py models/mnist文件目录里将有一个附加的实体模型文件夹名称来储存实体模型。
运作TF服务项目。
dockerrun -p 8500:8500 --mounttype=bind,source=$(pwd)/models/mnist,target=/models/mnist -e MODEL_NAME=mnist -t tensorflow/servingtensorflow-service-API已安裝。
pip install tensorflow-serving-api手机客户端身份认证
/root/anaconda3/bin/pythontensorflow_serving/example/mnist_client.py --num_tests=1000--server=127.0.0.1:8500逻辑推理差错率:10.4%
第二,立即安裝tensorflow_model_server。
删掉已安裝的tensorflow_model_server。
apt-getremove tensorflow-model-server加上服务项目头型URI做为包源。
echo "deb[arch=amd64] http://storage.googleapis.com/tensorflow-serving-apt stabletensorflow-model-server tensorflow-model-server-universal" | sudo tee/etc/apt/sources.list.d/tensorflow-serving.list && curlhttps://storage.googleapis.com/tensorflow-serving-apt/tensorflow-serving.release.pub.gpg| sudo apt-key add –安裝偏微分流实体模型网络服务器
apt-getupdate && apt-get install tensorflow-model-server服务项目根据tensorflow_model_server运行。
tensorflow_model_server--port=8502 --rest_api_port=8503 --model_name=half_plus_two--model_base_path=/root/maoyaozong/tfserving/serving/tensorflow_serving/servables/tensorflow/testdata/saved_model_half_plus_two_cpu这儿大家以8502做为gRPC端口,8503做为restFull端口号逐渐。
认证服务
curl-d '{"instances": [1.0, 2.0, 5.0]}' -X POST http://localhost:8503/v1/models/half_plus_two:predict