Home

Awesome

<!-- # Copyright 2021-2022, NVIDIA CORPORATION & AFFILIATES. All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # * Neither the name of NVIDIA CORPORATION nor the names of its # contributors may be used to endorse or promote products derived # from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY # EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR # PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY # OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -->

License

OpenVINO Backend

Note: OpenVINO backend is beta quality. As a result you may encounter performance and functional issues that will be resolved in future releases.

The Triton backend for the OpenVINO. You can learn more about Triton backends in the backend repo. Ask questions or report problems in the main Triton issues page. The backend is designed to run models in Intermediate Representation (IR). See here for instruction to convert a model to IR format. The backend is implemented using openVINO C++ API. Auto completion of the model config is not supported in the backend and complete config.pbtxt must be provided with the model.

Supported Devices

OpenVINO backend currently supports inference only on Intel CPU devices using OpenVINO CPU plugin. Note the CPU plugin does not support iGPU.

Build the OpenVINO Backend

Cmake 3.17 or higher is required. First install the required dependencies.

$ apt-get install patchelf rapidjson-dev python3-dev

Follow the steps below to build the backend shared library.

$ mkdir build
$ cd build
$ cmake -DCMAKE_INSTALL_PREFIX:PATH=`pwd`/install -DTRITON_BUILD_OPENVINO_VERSION=2024.4.0 -DTRITON_BUILD_CONTAINER_VERSION=24.03 ..
$ make install

The following required Triton repositories will be pulled and used in the build. By default the "main" branch/tag will be used for each repo but the listed CMake argument can be used to override.

Using the OpenVINO Backend

Parameters

Configuration of OpenVINO for a model is done through the Parameters section of the model's 'config.pbtxt' file. The parameters and their description are as follows.

Auto-Complete Model Configuration

Assuming Triton was not started with --disable-auto-complete-config command line option, the OpenVINO Backend makes use of the model configuration available in OpenVINO models to populate the required fields in the model's "config.pbtxt". You can learn more about Triton's support for auto-completing model configuration from here.

However, not all OpenVINO models carry sufficient configuration information to auto-complete the model's "config.pbtxt". As a result, a partial "config.pbtxt" could still be required for some models.

OpenVINO backend can complete the following fields in model configuration:

max_batch_size

Auto-completing max_batch_size follows the following rules:

If the above two rules are met, max_batch_size is set to default-max-batch-size. Otherwise max_batch_size is set as 0.

Inputs and Outputs

The OpenVINO Backend is able to fill in the name, data_type, and dims provided this information is available in the model.

Autocompleting inputs/outputs follows the following rules:

Dynamic Batching

If max_batch_size > 1, after auto-completing max_batch_size, and no dynamic_batching and sequence_batching is provided, then dynamic_batching will be enabled with default settings.

Examples of the "config.pbtxt" file sections depending on the use case

Latency mode

Latency mode with low concurrency on the client side. Recommended for performance optimization with low number of parallel clients.

parameters: [
{
   key: "NUM_STREAMS"
   value: {
     string_value: "1"
   }
},
{
   key: "PERFORMANCE_HINT"
   value: {
     string_value: "LATENCY"
   }
}
]

Throughput mode

Throughput mode with high concurrency on the client side. Recommended for throughput optimization with high number of parallel clients. Number of streams should be lower or equal to number of parallel clients and lower of equal to the number of CPU cores. For example, with ~20 clients on the host with 12 CPU cores, the config could be like:

instance_group [
    {
      count: 12
      kind: KIND_CPU
    }
  ]
parameters: [
{
   key: "NUM_STREAMS"
   value: {
     string_value: "12"
   }
}
]

Loading non default model format

When loading model with the non default format of Intermediate Representation and the name model.xml, use and extra parameter "default_model_filename". For example, using TensorFlow saved_model format use:

default_model_filename: "model.saved_model"

and copy the model to the subfolder called "model.saved_model"

model_repository/
└── model
    ├── 1
    │   └── model.saved_model
    │       ├── saved_model.pb
    │       └── variables
    └── config.pbtxt

Other allowed values are model.pdmodel or model.onnx.

Reshaping models

Following section shows how to use OpenVINO dynamic shapes. -1 denotes dimension accepting any value on input. In this case while model originally accepted input with layout NCHW and shape (1,3,224,224), now it accepts any batch size and resolution.

Note: If the model is originally exported with dynamic shapes, there is no need to manually specify dynamic shapes in config.

Note: Some models might not support a shape with an arbitrary dimension size. An error will be raised during the model initialization when the shaped in the config.pbtxt is not possible. Clients will also receive an error if the request includes unsupported input shapes.

input [
  {
    name: "input"
    data_type: TYPE_FP32
    dims: [ -1, 3, -1, -1]
  }
]
output [
  {
    name: "output"
    data_type: TYPE_FP32
    dims: [ -1, 1001]
  }
]
parameters: {
key: "RESHAPE_IO_LAYERS"
value: {
string_value:"yes"
}
}

Known Issues