Using CLI
Guide to start using Konduit-Serving with CLI
This document will demonstrate using Konduit-Serving using mainly CLI tools. You can deploy ML/DL models to production using minimal effort using Konduit-Serving. Let's look at the process of building and installing Konduit-Serving from source and how to deploy a model using a simple configuration.
Prerequisite
You will need following prerequisites to follow along
Maven 3.x
JDK 8
Git
Installation from Sources
The following two sections explains how to clone, build and install Konduit-Serving from sources.
To build from source, follow the guide below
Building from sourceTo install the respective built binaries you can navigate to the section below
Installing BinariesAfter you've installed Konduit-Serving in your local machine you can switch to a terminal and verify the installation by running
konduit --version
You'll see an output similar to the one below
$ konduit --version
------------------------------------------------
Version: 0.1.0-SNAPSHOT
Commit hash: 3dd38832
Commit time: 01.03.2021 @ 03:37:08 MYT
Build time: 07.03.2021 @ 16:57:51 MYT
Deploying Models
Let's look at how to deploy a dl4j/keras model using Konduit-Serving
Cloning Examples Repo
Let's clone the konduit-serving-examples
repo
git clone https://github.com/KonduitAI/konduit-serving-examples.git
and navigate to the quickstart
folder
cd konduit-serving-demo/quickstart
The examples we want to run are under the folders 3-keras-mnist
and 5-dl4j-mnist
. Let's follow a basic workflow for both models using the Konduit-Serving CLI.
Navigate to 3-keras-mnist
cd 3-keras-mnist
Here, you'll find the following files:
.
├── keras-mnist.ipynb | A supplementary jupyter/beakerx notebook
├── keras.h5 | Model file we want to serve
├── keras.json | Konduit-Serving configuration
├── test-image.jpg | Test input for predictions
└── train.py | Script for creating 'keras.h5' model file
The keras.json
contains the configuration file for running an MNIST dataset trained model in Keras. To serve the model, execute the following command
konduit serve --config keras.json -id keras-server
You'll be able to see a similar output like the following
.
.
.
15:00:08.575 [vert.x-worker-thread-0] INFO a.k.s.m.d.step.DL4JRunner -
15:00:08.576 [vert.x-worker-thread-0] INFO a.k.s.v.verticle.InferenceVerticle -
####################################################################
# #
# | / _ \ \ | _ \ | | _ _| __ __| | / | / #
# . < ( | . | | | | | | | . < . < #
# _|\_\ \___/ _|\_| ___/ \__/ ___| _| _|\_\ _) _|\_\ _) #
# #
####################################################################
15:00:08.576 [vert.x-worker-thread-0] INFO a.k.s.v.verticle.InferenceVerticle - Pending server start, please wait...
.
.
.
.
15:00:08.752 [vert.x-eventloop-thread-0] INFO a.k.s.v.p.h.v.InferenceVerticleHttp - Inference HTTP server is listening on host: 'localhost'
15:00:08.752 [vert.x-eventloop-thread-0] INFO a.k.s.v.p.h.v.InferenceVerticleHttp - Inference HTTP server started on port 40987 with 4 pipeline steps
The last line will show you the details about which URL the server is serving the models at.
Press Ctrl + C
, or execute konduit stop keras-server
to kill the server.
To run the server in the background, you can run the same command with the --background
or -b
flag.
konduit serve --config keras.json -id keras-server --background
You'll see something similar to
Starting konduit server...
Expected classpath: /Users/konduit/Projects/Konduit/konduit-serving/konduit-serving-tar/target/konduit-serving-tar-0.1.0-SNAPSHOT-dist/bin/../konduit.jar
INFO: Running command /Users/konduit/opt/miniconda3/jre/bin/java -Dkonduit.logs.file.path=/Users/konduit/.konduit-serving/command_logs/keras-server.log -Dlogback.configurationFile=/Users/konduit/Projects/Konduit/konduit-serving/konduit-serving-tar/target/konduit-serving-tar-0.1.0-SNAPSHOT-dist/bin/../conf/logback-run_command.xml -cp /Users/konduit/Projects/Konduit/konduit-serving/konduit-serving-tar/target/konduit-serving-tar-0.1.0-SNAPSHOT-dist/bin/../konduit.jar ai.konduit.serving.cli.launcher.KonduitServingLauncher run --instances 1 -s inference -c keras.json -Dserving.id=keras-server
For server status, execute: 'konduit list'
For logs, execute: 'konduit logs keras-server'
To list the server, simply run
konduit list
You'll see the running servers as a list
Listing konduit servers...
# | ID | TYPE | URL | PID | STATUS
1 | keras-server | inference | localhost:1000 | 1200 | Started
To view the logs, you can run the following command
konduit logs keras-server --lines 2
The --lines
or -l
flag shows the specified number of last lines. By executing the above command you'll see the following
15:00:08.752 [vert.x-eventloop-thread-0] INFO a.k.s.v.p.h.v.InferenceVerticleHttp - Inference HTTP server is listening on host: 'localhost'
15:00:08.752 [vert.x-eventloop-thread-0] INFO a.k.s.v.p.h.v.InferenceVerticleHttp - Inference HTTP server started on port 1000 with 4 pipeline steps
Now finally, let's look at running predictions with Konduit-Serving by sending an image file to the server.
konduit predict keras-server -it multipart '[email protected]'
It will convert the image into an n-dimensional array and then send the input to the keras model and you'll see the following output
{
"output_layer" : [ [ 9.0376153E-7, 1.0595608E-8, 1.3115231E-5, 0.44657645, 6.748624E-12, 0.5524258, 1.848306E-7, 2.7652052E-9, 9.76023E-4, 7.5933513E-6 ] ],
"prob" : 0.5524258017539978,
"index" : 5,
"label" : "5"
}
Congratulations! You've learned the basic workflow for Konduit-Serving using the Command Line Interface.
Last updated
Was this helpful?