mirror of
https://github.com/clearlinux/dockerfiles.git
synced 2026-11-22 05:42:47 +00:00
add tensorflow-serving container
Signed-off-by: Liu, Jianjun <jianjun.liu@intel.com>
This commit is contained in:
@@ -31,6 +31,7 @@ env:
|
||||
- DOCKERFILE_DIR=redis
|
||||
- DOCKERFILE_DIR=ruby
|
||||
- DOCKERFILE_DIR=tensorflow
|
||||
- DOCKERFILE_DIR=tensorflow-serving
|
||||
- DOCKERFILE_DIR=tomcat
|
||||
- DOCKERFILE_DIR=wordpress
|
||||
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
FROM clearlinux:latest AS builder
|
||||
MAINTAINER jianjun.liu@intel.com
|
||||
|
||||
ARG swupd_args
|
||||
# Move to latest Clear Linux release to ensure
|
||||
# that the swupd command line arguments are
|
||||
# correct
|
||||
RUN swupd update --no-boot-update $swupd_args
|
||||
|
||||
# Grab os-release info from the minimal base image so
|
||||
# that the new content matches the exact OS version
|
||||
COPY --from=clearlinux/os-core:latest /usr/lib/os-release /
|
||||
|
||||
# Install additional content in a target directory
|
||||
# using the os version from the minimal base
|
||||
RUN source /os-release && \
|
||||
mkdir /install_root \
|
||||
&& swupd os-install -V ${VERSION_ID} \
|
||||
--path /install_root --statedir /swupd-state \
|
||||
--bundles=os-core,tensorflow-serving --no-boot-update
|
||||
|
||||
# For some Host OS configuration with redirect_dir on,
|
||||
# extra data are saved on the upper layer when the same
|
||||
# file exists on different layers. To minimize docker
|
||||
# image size, remove the overlapped files before copy.
|
||||
RUN mkdir /os_core_install
|
||||
COPY --from=clearlinux/os-core:latest / /os_core_install/
|
||||
RUN cd / && \
|
||||
find os_core_install | sed -e 's/os_core_install/install_root/' | xargs rm -d &> /dev/null || true
|
||||
|
||||
FROM clearlinux/os-core:latest
|
||||
|
||||
COPY --from=builder /install_root /
|
||||
|
||||
# Expose ports
|
||||
# gRPC
|
||||
EXPOSE 8500
|
||||
|
||||
# REST
|
||||
EXPOSE 8501
|
||||
|
||||
# Set where models should be stored in the container
|
||||
ENV MODEL_BASE_PATH=/models
|
||||
RUN mkdir -p ${MODEL_BASE_PATH}
|
||||
|
||||
# The only required piece is the model name in order to differentiate endpoints
|
||||
ENV MODEL_NAME=model
|
||||
|
||||
# Copy the script that runs the model server so we can use environment variables
|
||||
RUN mkdir -p /usr/local/bin
|
||||
COPY tf_serving_entrypoint.sh /usr/local/bin/
|
||||
RUN chmod +x /usr/local/bin/tf_serving_entrypoint.sh
|
||||
|
||||
ENTRYPOINT ["tf_serving_entrypoint.sh"]
|
||||
@@ -0,0 +1,101 @@
|
||||
# Clear Linux* OS `tensorflow-serving` container image
|
||||
|
||||
<!-- Required -->
|
||||
## What is this image?
|
||||
|
||||
`clearlinux/tensorflow-serving` is a Docker image with `tensorflow-serving` running on top of the
|
||||
[official clearlinux base image](https://hub.docker.com/_/clearlinux).
|
||||
|
||||
<!-- application introduction -->
|
||||
> [Tensorflow-serving](https://www.tensorflow.org/serving) is a flexible,
|
||||
> high-performance serving system for machine learning models.
|
||||
|
||||
For other Clear Linux* OS
|
||||
based container images, see: https://hub.docker.com/u/clearlinux
|
||||
|
||||
## Why use a clearlinux based image?
|
||||
|
||||
<!-- CL introduction -->
|
||||
> [Clear Linux* OS](https://clearlinux.org/) is an open source, rolling release
|
||||
> Linux distribution optimized for performance and security, from the Cloud to
|
||||
> the Edge, designed for customization, and manageability.
|
||||
|
||||
Clear Linux* OS based container images use:
|
||||
* Optimized libraries that are compiled with latest compiler versions and
|
||||
flags.
|
||||
* Software packages that follow upstream source closely and update frequently.
|
||||
* An aggressive security model and best practices for CVE patching.
|
||||
* A multi-staged build approach to keep a reduced container image size.
|
||||
* The same container syntax as the official images to make getting started
|
||||
easy.
|
||||
|
||||
To learn more about Clear Linux* OS, visit: https://clearlinux.org.
|
||||
|
||||
<!-- Required -->
|
||||
## Deployment:
|
||||
|
||||
### Deploy with Docker
|
||||
The easiest way to get started with this image is by simply pulling it from
|
||||
Docker Hub.
|
||||
|
||||
*Note: This container uses the same syntax as the [official tensorflow-serving image](https://hub.docker.com/_/tensorflow-serving).
|
||||
|
||||
|
||||
1. Pull the image from Docker Hub:
|
||||
```
|
||||
docker pull clearlinux/tensorflow-serving
|
||||
```
|
||||
|
||||
2. Download a tensorflow-serving repo and setup the location of demo models
|
||||
```
|
||||
git clone https://github.com/tensorflow/serving
|
||||
TESTDATA="$(pwd)/serving/tensorflow_serving/servables/tensorflow/testdata"
|
||||
```
|
||||
3. Start a container using the examples below:
|
||||
|
||||
```
|
||||
docker run -t --rm -p 8501:8501 \
|
||||
-v "$TESTDATA/saved_model_half_plus_two_cpu:/models/half_plus_two" \
|
||||
-e MODEL_NAME=half_plus_two \
|
||||
clearlinux/tensorflow-serving &
|
||||
```
|
||||
4. Query the model using the predict API and the return => { "predictions": [2.5, 3.0, 4.5] }
|
||||
|
||||
```
|
||||
curl -d '{"instances": [1.0, 2.0, 5.0]}' \
|
||||
-X POST http://localhost:8501/v1/models/half_plus_two:predict
|
||||
```
|
||||
<!-- Required -->
|
||||
## Build and modify:
|
||||
|
||||
The Dockerfiles for all Clear Linux* OS based container images are available at
|
||||
https://github.com/clearlinux/dockerfiles. These can be used to build and
|
||||
modify the container images.
|
||||
|
||||
1. Clone the clearlinux/dockerfiles repository.
|
||||
```
|
||||
git clone https://github.com/clearlinux/dockerfiles.git
|
||||
```
|
||||
|
||||
2. Change to the directory of the application:
|
||||
```
|
||||
cd tensorflow-serving/
|
||||
```
|
||||
|
||||
3. Build the container image:
|
||||
```
|
||||
docker build -t clearlinux/tensorflow-serving .
|
||||
```
|
||||
|
||||
Refer to the Docker documentation for [default build arguments](https://docs.docker.com/engine/reference/builder/#arg).
|
||||
Additionally:
|
||||
|
||||
- `swupd_args` - specifies arguments to pass to the Clear Linux* OS software
|
||||
manager. See the [swupd man pages](https://github.com/clearlinux/swupd-client/blob/master/docs/swupd.1.rst#options)
|
||||
for more information.
|
||||
|
||||
<!-- Required -->
|
||||
## Licenses
|
||||
|
||||
All licenses for the Clear Linux* Project and distributed software can be found
|
||||
at https://clearlinux.org/terms-and-policies
|
||||
@@ -0,0 +1,6 @@
|
||||
#!/bin/bash
|
||||
|
||||
|
||||
tensorflow_model_server --port=8500 --rest_api_port=8501 \
|
||||
--model_name=${MODEL_NAME} --model_base_path=${MODEL_BASE_PATH}/${MODEL_NAME} \
|
||||
"$@"
|
||||
Reference in New Issue
Block a user