취미가 좋다

Triton Client 본문

Data Engineer/triton inference server

Triton Client

benlee73 2021. 6. 29. 15:08

https://github.com/triton-inference-server/client

 

Triton Client Libraries and Examples

triton 과의 통신을 간편하게 하기 위해, 여러 클라이언트 라이브러리와 그 라이브러리를 사용하는 예시를 제공한다.

 

C++ / python APIs 는 triton과 통신하기 쉽다.

HTTP/REST or GRPC 요청 모두 가능하고, 아래의 것들을 수행할 수 있다.

inferencing, status and health, statistics and metrics, model repository management, etc.

example model repository 에서 여러 예시를 사용해볼 수 있다.

 

Getting the Client Libraries And Examples

가장 쉬운 방법으로는 pip 로 설치하는 것이다.

triton github release, docker image 로도 다운로드 받을 수 있고, cmake 로 빌드할 수도 있다.

 

Client Library APIs

 

Simple Example Applications

Bytes/String Datatype

 

System Shared Memory

system shared memory 를 사용하여 client library와 triton 간에 텐서를 통신하게 되면, 성능을 향상시킬 수 있다.

python에는 shared memory를 할당하고 접근하는 standard 방법이 없기 때문에, 간단한 예시 모듈을 제공한다.

이 예시는 python client library를 사용하여 system shared memory를 생성하고 설정하고 삭제할 수 있도록 한다.

https://github.com/triton-inference-server/client/tree/main/src/python/examples

 

CUDA Shared Memory

마찬가지로 성능 향상을 이룬다.

위와 동일하게 python에 예시 모듈을 제공한다.

 

Client API for Stateful Models

 

Image Classification Example

https://github.com/triton-inference-server/client/blob/main/src/python/examples/image_client.py

먼저 triton 서버로 하나 이상의 image classification 모델 서빙

이미지 입력을 보내서 결과를 얻어올 수 있다.

$ python image_client.py -m inception_graphdef -s INCEPTION qa/images/mug.jpg
Request 0, batch size 1
Image 'qa/images/mug.jpg':
     0.826384 (505) = COFFEE MUG

 

  • -i : client library가 HTTP/REST 프로토콜을 사용하도록 기본 값 설정이 되어 있고, -i flag 를 통해 GRPC 프로토콜로 변경할 수도 있다.
  • -c : probability 가 높은 상위 항목들을 보려면 -c flag를 사용하면 된다.
  • -b : inferencing 할 때, 이미지를 배치 단위로 보낼 수 있다. 만약 배치가 이미지 수보다 많다면, 배치를 채우도록 이미지를 복사한다.
  • 하나의 이미지 대신 디렉토리를 지정하여, 디렉토리 내 모든 이미지에 대해 inference 를 수행할 수 있다.
$ image_client -m inception_graphdef -s INCEPTION -c 3 -b 2 qa/images
Request 0, batch size 2
Image '/opt/tritonserver/qa/images/car.jpg':
    0.819196 (818) = SPORTS CAR
    0.033457 (437) = BEACH WAGON
    0.031232 (480) = CAR WHEEL
Image '/opt/tritonserver/qa/images/mug.jpg':
    0.754130 (505) = COFFEE MUG
    0.157077 (969) = CUP
    0.002880 (968) = ESPRESSO
Request 1, batch size 2
Image '/opt/tritonserver/qa/images/vulture.jpeg':
    0.977632 (24) = VULTURE
    0.000613 (9) = HEN
    0.000560 (137) = EUROPEAN GALLINULE
Image '/opt/tritonserver/qa/images/car.jpg':
    0.819196 (818) = SPORTS CAR
    0.033457 (437) = BEACH WAGON
    0.031232 (480) = CAR WHEEL

 

Ensemble Image Classification Example Application

DALI 백엔드를 앙상블하여 사용할 수 있다.

앙상블 모델을 사용하면, client 에서 이미지를 전처리 하지 않고 원본 이미지 binaries 만 보내고도 classification 결과를 얻을 수 있다.

 

'Data Engineer > triton inference server' 카테고리의 다른 글

[ Server ] Model Management  (0) 2021.07.23
[ Server ] Model Repository  (0) 2021.06.29
[ Server ] Quickstart  (0) 2021.06.29
[ Server ] Inference protocols  (0) 2021.06.28
[ Server ] build  (0) 2021.06.28
Comments