TensorFlow Serving,GPU版安装
来源:互联网 发布:辐射4提取脸部数据 编辑:程序博客网 时间:2024/05/29 17:36
TensorFlow Serving,GPU
Tensorflow serving 是一个开源的工具,主要用来部署训练好的模型,进行Inference。
Tensorflow serving Github地址
本文主要介绍tensorflow serving的安装,支持GPU模型。
安装依赖
Bazel
TensorFlow Serving 要求0.4.5以上的Bazel。Bazel 的安装说明here
- 下载安装脚本here。以 bazel-0.4.5-installer-linux-x86_64.sh为例子,
chmod +x bazel-0.4.5-installer-linux-x86_64.sh./bazel-0.4.5-installer-linux-x86_64.sh --user
列表内容
加入环境变量到 ~/.bashrc中
export PATH="$PATH:$HOME/bin"
gRPC
使用 pip 安装,很方便。
sudo pip install grpcio
Packages
其他需要的依赖包
sudo apt-get update && sudo apt-get install -y \ build-essential \ curl \ libcurl3-dev \ git \ libfreetype6-dev \ libpng12-dev \ libzmq3-dev \ pkg-config \ python-dev \ python-numpy \ python-pip \ software-properties-common \ swig \ zip \ zlib1g-dev
源码安装
git clone --recurse-submodules https://github.com/tensorflow/servingcd serving
官网的例子没有使用GPU,所以部署自己的模型的时候,速度会比较慢(InceptionV3可能要10+s)。支持GPU版本的配置。compile_tensorflow_serving.sh
请根据自己的GPU和文件路径之类的做相应的替换。
执行以下命令,就会进行编译了 server了。
./compile_tensorflow_serving.sh
编译成功的话,model server在以下路径执行。
bazel-bin/tensorflow_serving/model_servers/tensorflow_model_server
如果external/nccl_archive/src/nccl.h: No such file or directory错误,需要另外安装nccl
git clone https://github.com/NVIDIA/nccl.gitcd nccl/make CUDA_HOME=/usr/local/cudasudo make installsudo mkdir -p /usr/local/include/external/nccl_archive/srcsudo ln -s /usr/local/include/nccl.h /usr/local/include/external/nccl_archive/src/nccl.h
部署mnist模型
训练一个简单的模型,然后保存。细节可以参考Basic Serving Tutorial
rm -rf /tmp/mnist_modelbazel build //tensorflow_serving/example:mnist_saved_modelbazel-bin/tensorflow_serving/example/mnist_saved_model /tmp/mnist_modelTraining model......Done training!Exporting trained model to /tmp/mnist_modelDone exporting!
启动tensorflow model server,
bazel-bin/tensorflow_serving/model_servers/tensorflow_model_server --port=9000 --model_name=mnist --model_base_path=/tmp/mnist_model/
这时候使用nvidia-smi查看显存状态,可以看到server是否已经正常使用GPU。
测试mnist的效果
bazel build //tensorflow_serving/example:mnist_clientbazel-bin/tensorflow_serving/example/mnist_client --num_tests=1000 --server=localhost:9000
阅读全文
0 0
- TensorFlow Serving,GPU版安装
- 安装tensorflow serving总结
- TensorFlow Serving 01 安装
- TensorFlow GPU版安装
- win10 安装 tensorflow gpu 版
- Windows10安装GPU版Tensorflow
- win10安装GPU版tensorflow
- tensorflow(GPU版)安装
- win10 安装 tensorflow gpu 版
- Windows10 安装tensorflow GPU版
- Tensorflow serving(tf_serving) 安装测试说明
- 简单安装tensorflow-gpu(GPU版tensorflow)
- Win10下安装Tensorflow(GPU版)
- GPU版Tensorflow安装 centos7 64位
- win7安装tensorflow-gpu版(Anaconda)
- Ubuntu16.04安装tensorflow-gpu版
- 在Windows上安装GPU版Tensorflow
- window10 GPU版tensorflow安装(一)
- ECMA-262个人补充
- Linux_博客-URG-PSH
- Bugzilla使用
- Shape的使用---带色的圆点
- Excel VBA选择文件、高容错性地打开文件
- TensorFlow Serving,GPU版安装
- Leetcode Maze 总结
- PAT乙级1023. 组个最小数 (20)
- EXCEL VBA 正则表达式
- 移动端WEB开发,click,touch,tap事件浅析
- oracle order by 处理NULL 值
- python练习2
- Session机制详解
- 【剑指offer】题51:数组中重复的数字