ubuntu+docker+tensorflow-serving2.2+tensorflow2.2


1.虛擬機安裝ubuntu16.04

(1)下載ubuntu的鏡像,下載地址為:http://mirrors.aliyun.com/ubuntu-releases/16.04/
推薦使用迅雷下載。
(2)安裝ubuntu的時候,需要離線安裝。
(3)如果遇到虛擬機屏幕無法自適應大小的問題,可以嘗試安裝vmware tool或者在編輯中將其改為自適應窗口。

2.安裝anaconda、tensorflow2.2.0

(1)為apt安裝清華源
sudo cp /etc/apt/sources.list /etc/apt/sources_init.list
sudo gedit /etc/apt/sources.list
然后,將list內容修改為清華大學鏡像。

deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-updates main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-backports main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-backports main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-security main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-security main restricted universe multiverse

# 預發布軟件源,不建議啟用
# deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-proposed main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-proposed main restricted universe multiverse

(2)使用anaconda的sh腳本進行安裝
鏡像地址:https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/
bash Anaconda3-4.2.0-Linux-x86_64.sh
(3)安裝tensorflow2.2

  • pip install tensorflow==2.2.0 -i https://pypi.tuna.tsinghua.edu.cn/simple 使用pip安裝可能會超時
  • 直接使用whl文件進行安裝 pip install tensorflow-2.2.0-cp37-cp37m-manylinux2010_x86_64.whl

3.安裝docker

(1)sudo apt install apt-transport-https ca-certificates curl software-properties-common
(2)在/etc/apt/sources.list.d/docker.list文件中添加下面內容:deb [arch=amd64] https://download.docker.com/linux/ubuntu bionic stable
(3)curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
(4)sudo apt install docker-ce
(5)查看服務是否啟動:systemctl status docker
(6)啟動服務:sudo systemctl start docker
(7)測試hello world:docker run hello-world

4.docker中安裝tensorflow-serving

(1)在etc/docker中建立daemon.json文件,並且添加阿里雲鏡像:
{
"registry-mirrors": ["https://9cpn8tt6.mirror.aliyuncs.com"]
}
(2)systemctl daemon-reload
systemctl restart docker
(3)docker pull tensorflow/serving:latest-devel
(4)查看鏡像:sudo docker images

5.安裝tensorflow-serving-api

pip install tensorflow-serving-api==2.2.0 -i https://pypi.tuna.tsinghua.edu.cn/simple

6.使用tensorflow serving進行模型部署

tensorflow serving 可以提供grpc和rest api兩種遠程連接的方式,可以進行模型的熱部署和更新,非常方便。

7.安裝grpc

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
pip install grpcio

7.ubuntu安裝openssh-server

sudo apt-get install openssh-server

8.使用tensorflow-serving進行模型部署

tensorflow-serving進行模型部署,可以提供兩種API進行遠程調用,一種是grpc,一種是rest。並且,支持多個模型部署、模型版本動態更新、別名部署。
tensorflow-serving同時支持熱部署。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM