Optimize tensorflow_serving workflow
This commit is contained in:
parent
d19ff1a8be
commit
ed3641a66a
41
.github/workflows/build_and_push_ci_image.yml
vendored
41
.github/workflows/build_and_push_ci_image.yml
vendored
@ -11,7 +11,7 @@ on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
image_name:
|
||||
description: 'image name (must choose from <grpc, gvisor_test, openvino, python>)'
|
||||
description: 'image name (must choose from <grpc, gvisor_test, openvino, python, tf_serving>)'
|
||||
required: true
|
||||
default: 'grpc'
|
||||
tag:
|
||||
@ -175,3 +175,42 @@ jobs:
|
||||
build-args: OCCLUM_VERSION=${{ env.OCCLUM_VERSION }}
|
||||
push: true
|
||||
tags: occlumbackup/occlum:${{ github.event.inputs.tag }}-ubuntu18.04-python
|
||||
|
||||
Build_tf_serving_image:
|
||||
runs-on: ubuntu-18.04
|
||||
if: github.event.inputs.image_name == 'tf_serving'
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Get occlum version
|
||||
run: echo "OCCLUM_VERSION=$(grep 'Version =' src/pal/include/occlum_version.h | awk '{print $4}')" >> $GITHUB_ENV;
|
||||
|
||||
# Because "Build and push" step `context` field can't be subdir,
|
||||
# we need to copy files needed by dockerfile to root dir of the project
|
||||
- name: Copy context for docker build
|
||||
run: |
|
||||
cp -r tools/docker .
|
||||
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v1
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v1
|
||||
|
||||
- name: Login to DockerHub
|
||||
uses: docker/login-action@v1
|
||||
with:
|
||||
username: ${{ secrets.DOCKER_USERNAME }}
|
||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||
|
||||
- name: Build and push
|
||||
uses: docker/build-push-action@v2
|
||||
with:
|
||||
context: .
|
||||
file: ./tools/docker/ci/Dockerfile.tf_serving
|
||||
platforms: linux/amd64
|
||||
build-args: OCCLUM_VERSION=${{ env.OCCLUM_VERSION }}
|
||||
push: true
|
||||
tags: occlumbackup/occlum:${{ github.event.inputs.tag }}-ubuntu18.04-tf_serving
|
||||
|
17
.github/workflows/demo_test.yml
vendored
17
.github/workflows/demo_test.yml
vendored
@ -692,29 +692,24 @@ jobs:
|
||||
- name: Run Bash test
|
||||
run: docker exec bash_test bash -c "cd /root/occlum/demos/bash && SGX_MODE=SIM ./run_bash_demo.sh"
|
||||
|
||||
Tensorflow_serving_test:
|
||||
# Tensorflow_serving requires binary tensorflow_serving PIC, here we compile tensorflow_model_server before workflow
|
||||
tensorflow_serving_test:
|
||||
runs-on: ubuntu-18.04
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
with:
|
||||
submodules: true
|
||||
|
||||
- name: Get occlum version
|
||||
run: echo "OCCLUM_VERSION=$(grep "Version =" src/pal/include/occlum_version.h | awk '{print $4}')" >> $GITHUB_ENV
|
||||
|
||||
- name: Compile the tensorflow_serving with PIC
|
||||
run: |
|
||||
cd $GITHUB_WORKSPACE/demos/tensorflow/tensorflow_serving;
|
||||
./build_occlum_tf_serving.sh
|
||||
|
||||
- name: Create container
|
||||
run: docker run -itd --name=tf_serving_test -v $GITHUB_WORKSPACE:/root/occlum occlum/occlum:${{ env.OCCLUM_VERSION }}-ubuntu18.04
|
||||
run: docker run -itd --name=tf_serving_test -v $GITHUB_WORKSPACE:/root/occlum occlumbackup/occlum:latest-ubuntu18.04-tf_serving
|
||||
|
||||
- name: Build dependencies
|
||||
run: docker exec tf_serving_test bash -c "cd /root/occlum; make submodule"
|
||||
|
||||
- name: Make install
|
||||
run: docker exec tf_serving_test bash -c "source /opt/intel/sgxsdk/environment; cd /root/occlum; OCCLUM_RELEASE_BUILD=1 make install"
|
||||
|
||||
- name: Move tensorflow_model_server
|
||||
run: docker exec tf_serving_test bash -c "mv /root/tensorflow_model_server /root/occlum/demos/tensorflow/tensorflow_serving"
|
||||
|
||||
- name: Set up environment
|
||||
run: docker exec tf_serving_test bash -c "cd /root/occlum/demos/tensorflow/tensorflow_serving; ./prepare_model_and_env.sh"
|
||||
|
@ -26,8 +26,9 @@ This set of demos shows how real-world apps can be easily run inside SGX enclave
|
||||
* [redis](redis/): A demo of [Redis](https://redis.io).
|
||||
* [sofaboot](sofaboot/): A demo of [SOFABoot](https://github.com/sofastack/sofa-boot), an open source Java development framework based on Spring Boot.
|
||||
* [sqlite](sqlite/) A demo of [SQLite](https://www.sqlite.org) SQL database engine.
|
||||
* [tensorflow](tensorflow/): A demo of [TensorFlow](https://www.tensorflow.org/) MNIST classification training.
|
||||
* [tensorflow](tensorflow/tensorflow_training): A demo of [TensorFlow](https://www.tensorflow.org/) MNIST classification training.
|
||||
* [tensorflow_lite](tensorflow_lite/): A demo and benchmark of [TensorFlow Lite](https://www.tensorflow.org/lite) inference engine.
|
||||
* [tensorflow_serving](tensorflow/tensorflow_serving): A demo of [TensorFlow Serving](https://github.com/tensorflow/serving)
|
||||
* [vault](golang/vault/): A demo of [HashiCorp Vault](https://github.com/hashicorp/vault).
|
||||
* [xgboost](xgboost/): A demo of [XGBoost](https://xgboost.readthedocs.io/en/latest).
|
||||
|
||||
|
40
tools/docker/ci/Dockerfile.tf_serving
Normal file
40
tools/docker/ci/Dockerfile.tf_serving
Normal file
@ -0,0 +1,40 @@
|
||||
ARG OCCLUM_VERSION
|
||||
|
||||
FROM tensorflow/serving:latest-devel as binary_build
|
||||
WORKDIR /tensorflow-serving
|
||||
# Build, and install TensorFlow Serving
|
||||
ARG TF_SERVING_BUILD_OPTIONS="--config=nativeopt"
|
||||
RUN echo "Building with build options: ${TF_SERVING_BUILD_OPTIONS}"
|
||||
ARG TF_SERVING_BAZEL_OPTIONS=""
|
||||
RUN echo "Building with Bazel options: ${TF_SERVING_BAZEL_OPTIONS}"
|
||||
|
||||
RUN bazel build -j 8 --color=yes --curses=yes \
|
||||
${TF_SERVING_BAZEL_OPTIONS} \
|
||||
--verbose_failures \
|
||||
--force_pic \
|
||||
--output_filter=DONT_MATCH_ANYTHING \
|
||||
${TF_SERVING_BUILD_OPTIONS} \
|
||||
tensorflow_serving/model_servers:tensorflow_model_server && \
|
||||
cp bazel-bin/tensorflow_serving/model_servers/tensorflow_model_server \
|
||||
/usr/local/bin/
|
||||
|
||||
# Build and install TensorFlow Serving API
|
||||
RUN bazel build -j 8 --color=yes --curses=yes \
|
||||
${TF_SERVING_BAZEL_OPTIONS} \
|
||||
--force_pic \
|
||||
--verbose_failures \
|
||||
--output_filter=DONT_MATCH_ANYTHING \
|
||||
${TF_SERVING_BUILD_OPTIONS} \
|
||||
tensorflow_serving/tools/pip_package:build_pip_package && \
|
||||
bazel-bin/tensorflow_serving/tools/pip_package/build_pip_package \
|
||||
/tmp/pip && \
|
||||
pip --no-cache-dir install --upgrade \
|
||||
/tmp/pip/tensorflow_serving_api-*.whl && \
|
||||
rm -rf /tmp/pip
|
||||
|
||||
FROM occlum/occlum:$OCCLUM_VERSION-ubuntu18.04 as base
|
||||
LABEL maintainer="Zehuan Li <lizehuan.lzh@antgroup.com>"
|
||||
|
||||
WORKDIR /root
|
||||
COPY --from=binary_build /usr/local/bin/tensorflow_model_server /root/tensorflow_model_server
|
||||
|
Loading…
Reference in New Issue
Block a user