Thanks to visit codestin.com
Credit goes to github.com

Skip to content

pcoder93/hailo-triton-inference-server

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3,368 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Using Hailo AI accelerator with Nvidia Triton Server

We can leverage the triton server's python backend to customize it for use with ONNX Runtime and hailo-8 AI processor or intel OpenVINO compatible Devices.

THE WHY??

With the flexibility provided by the tritonserver python backend we can essentially run a chain of custom business logic required for our inference requests, example preprocessing and postprocessing for inference requests, chaining inference on different hardware, etc.

We can also customise our custom docker image to include necessary dependancies like Intel openVino:

Sample model repository

Please refer sample_models. It consists of a template hef_model with models.py which can be used with the triton server python backend for inference.

Building the triton server for hailo

Create the docker file using triton server build tool, this should create a base dockerfile in the build folder. This file can be used as base to customise like Dockefile.hailo_cpu

1. Download hailo dependancies

Register and download the latest hailort drivers from Hailo.ai developer-zone and save it to hailo/deps

2. Build

2.a. FOR CPU only

We NEED to build the tritonserver base image first before we build Dockefile.hailo_cpu.

python build.py \
  --backend onnxruntime \
  --backend python \
  --endpoint grpc \
  --endpoint http \
  --filesystem s3 \
  --enable-logging \
  --enable-stats \
  --enable-metrics \
  --enable-cpu-metrics \
  --enable-tracing

Now Build hailo triton server CPU-ONLY image using

docker build -t hailo-triton-server:r24.05-hailo4.19 -f Dockerfile.hailo_cpu .

2.b. FOR GPU support

We can use the existing base image offered by Nvidia like nvcr.io/nvidia/tritonserver:24.05-py3-min or build from scratch using following command

python build.py \
  --backend onnxruntime \
  --backend python \
  --backend pytorch \
  --endpoint grpc \
  --endpoint http \
  --filesystem s3 \
  --enable-logging \
  --enable-stats \
  --enable-metrics \
  --enable-cpu-metrics \
  --enable-tracing \
  --enable-gpu \
  --enable-gpu-metrics

Use the following command to build hailo triton server for use with Nvidia GPUs

docker build -t hailo-triton-server:r24.05-hailo4.19-gpu-py310 -f Dockerfile.hailo_gpu-py310 .

Note: the built image hailo-4.19-gpu-py310 is ONLY compatible with CUDA >=12.0 ref: Nvidia framework-matrix-2024

Test the docker image

Test if tritonserver was built successfully

docker run \
  --rm pcoder93/hailo-triton-server:r24.05-hailo4.19 tritonserver \
  --help

Test if container can access halio device

docker run \
  --rm \
  --device=/dev/hailo0:/dev/hailo0 \
  pcoder93/hailo-triton-server:r24.05-hailo4.19 hailortcli fw-control identify

Test if the container can access Intel openvino chips

docker run \
  --rm -it \
  --privileged \
  --device=/dev/dri:/dev/dri \
  --device=/dev/hailo0:/dev/hailo0 \
  pcoder93/hailo-triton-server:r24.05-hailo4.19 intel_gpu_top

Running the container

NOTE: Host should have the same version of hailo pcie driver installed

Create a model repository as shown Triton Model Repository layout

With Hailo and intel igpu

docker run \
  --rm \
  --name hailo-triton-server \
  --ulimit memlock=-1 \
  --ulimit stack=67108864 \
  --shm-size=2g \
  --device=/dev/hailo0:/dev/hailo0 \
  --device=/dev/dri:/dev/dri \
  -v /models/triton/<path to models-repository>:/app/data/models/triton:rw \
  -p 8001:8001 \
  -p 8002:8002 \
  pcoder93/hailo-triton-server:r24.05-hailo4.19 tritonserver \
  --model-repository="/app/data/models/triton"

With hailo and nvidia GPU:

docker run \
  --rm \
  --name hailo-triton \
  --ulimit memlock=-1 \
  --ulimit stack=67108864 \
  --shm-size=2g \
  --device=/dev/hailo0:/dev/hailo0 \
  --gpus=all \
  -v /models/triton/<path to models-repository>:/app/data/models/triton:rw \
  -p 8001:8001 \
  -p 8002:8002 \
  pcoder93/hailo-triton-server:r24.05-hailo4.19-gpu-py310 tritonserver \
  --model-repository="/app/data/models/triton" 

Using Triton Server on Raspberrypi

Nvidia provides prebuilt triton server images for arm devices like Nvidia Jetson Nano. We can use these as base to build.

Create a builder

docker buildx create --name archbuilder --use

Build image

docker buildx build \ 
  --platform linux/arm64 \
  -t pcoder93/hailo-triton-server:r24.06-hailort4.20-arm64 \
  --load \ 
  -f Dockerfile.hailo_cpu_arm64 .

Testing the image

docker run --rm -it \
  --platform linux/arm64 \
  pcoder93/hailo-triton-server:r24.06-hailort4.20-arm64 \ 
  -v <path to models>:/app/data/models \
  tritonserver --model-repository /app/data/models

Triton Inference Server

License

Triton Inference Server is an open source inference serving software that streamlines AI inferencing. Triton enables teams to deploy any AI model from multiple deep learning and machine learning frameworks, including TensorRT, TensorFlow, PyTorch, ONNX, OpenVINO, Python, RAPIDS FIL, and more. Triton Inference Server supports inference across cloud, data center, edge and embedded devices on NVIDIA GPUs, x86 and ARM CPU, or AWS Inferentia. Triton Inference Server delivers optimized performance for many query types, including real time, batched, ensembles and audio/video streaming. Triton inference Server is part of NVIDIA AI Enterprise, a software platform that accelerates the data science pipeline and streamlines the development and deployment of production AI.

Major features include:

New to Triton Inference Server? Make use of these tutorials to begin your Triton journey!

Join the Triton and TensorRT community and stay current on the latest product updates, bug fixes, content, best practices, and more. Need enterprise support? NVIDIA global support is available for Triton Inference Server with the NVIDIA AI Enterprise software suite.

Serve a Model in 3 Easy Steps

# Step 1: Create the example model repository
git clone -b r24.05 https://github.com/triton-inference-server/server.git
cd server/docs/examples
./fetch_models.sh

# Step 2: Launch triton from the NGC Triton container
docker run --gpus=1 --rm --net=host -v ${PWD}/model_repository:/models nvcr.io/nvidia/tritonserver:24.05-py3 tritonserver --model-repository=/models

# Step 3: Sending an Inference Request
# In a separate console, launch the image_client example from the NGC Triton SDK container
docker run -it --rm --net=host nvcr.io/nvidia/tritonserver:24.05-py3-sdk
/workspace/install/bin/image_client -m densenet_onnx -c 3 -s INCEPTION /workspace/images/mug.jpg

# Inference should return the following
Image '/workspace/images/mug.jpg':
    15.346230 (504) = COFFEE MUG
    13.224326 (968) = CUP
    10.422965 (505) = COFFEEPOT

Please read the QuickStart guide for additional information regarding this example. The quickstart guide also contains an example of how to launch Triton on CPU-only systems. New to Triton and wondering where to get started? Watch the Getting Started video.

Examples and Tutorials

Check out NVIDIA LaunchPad for free access to a set of hands-on labs with Triton Inference Server hosted on NVIDIA infrastructure.

Specific end-to-end examples for popular models, such as ResNet, BERT, and DLRM are located in the NVIDIA Deep Learning Examples page on GitHub. The NVIDIA Developer Zone contains additional documentation, presentations, and examples.

Documentation

Build and Deploy

The recommended way to build and use Triton Inference Server is with Docker images.

Using Triton

Preparing Models for Triton Inference Server

The first step in using Triton to serve your models is to place one or more models into a model repository. Depending on the type of the model and on what Triton capabilities you want to enable for the model, you may need to create a model configuration for the model.

Configure and Use Triton Inference Server

Client Support and Examples

A Triton client application sends inference and other requests to Triton. The Python and C++ client libraries provide APIs to simplify this communication.

Extend Triton

Triton Inference Server's architecture is specifically designed for modularity and flexibility

Additional Documentation

Contributing

Contributions to Triton Inference Server are more than welcome. To contribute please review the contribution guidelines. If you have a backend, client, example or similar contribution that is not modifying the core of Triton, then you should file a PR in the contrib repo.

Reporting problems, asking questions

We appreciate any feedback, questions or bug reporting regarding this project. When posting issues in GitHub, follow the process outlined in the Stack Overflow document. Ensure posted examples are:

  • minimal – use as little code as possible that still produces the same problem
  • complete – provide all parts needed to reproduce the problem. Check if you can strip external dependencies and still show the problem. The less time we spend on reproducing problems the more time we have to fix it
  • verifiable – test the code you're about to provide to make sure it reproduces the problem. Remove all other problems that are not related to your request/question.

For issues, please use the provided bug report and feature request templates.

For questions, we recommend posting in our community GitHub Discussions.

For more information

Please refer to the NVIDIA Developer Triton page for more information.

About

The Triton Inference Server provides an optimized cloud and edge inferencing solution.

Resources

License

Contributing

Security policy

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages

  • Python 54.4%
  • Shell 23.2%
  • C++ 18.3%
  • CMake 1.5%
  • Java 1.3%
  • Roff 0.9%
  • Other 0.4%