취미가 좋다
[ Server ] Quickstart 본문
Quickstart
trtion inference server는 빌드 가능한 소스 코드로 사용할 수 있지만, 가장 쉽게 설치하고 실행하는 방법은 NGC(Nvidia Gpu Cloud)에 이미 빌드된 도커 이미지를 사용하는 것이다.
Install Triton Docker Image
가장 먼저 도커를 설치해야 한다.
만약 inference 할 때, gpu를 사용할 것이라면 NIVIDIA Container Toolkit 도 설치해야 한다.
그리고 아래의 코드로 이미지를 가져온다.
$ docker pull nvcr.io/nvidia/tritonserver:<xx.yy>-py3
<xx.yy> 는 가져오고 싶은 triton의 버전을 의미한다.
Create A Model Repository
triton으로 서빙하고자 하는 모델을 가져와서, model repository 조건을 만족하도록 정해진 디렉토리에 넣는다.
제공된 script로 model zoo에서 누락된 model definition files 을 가져와야 한다.
$ cd docs/examples
$ ./fetch_models.sh
Run Triton
triton은 gpu를 사용하여 최고의 inference 성능을 내도록 최적화 되어있다. 물론 cpu만 사용할 수도 있다.
두 경우에서 같은 triton 도커 이미지를 사용할 수 있다.
Run on System with GPUs
아래의 코드로 생성한 예시 model repostiroy로 triton을 실행시킨다.
이 때, 도커가 gpu를 인식하게 하려면 NVIDIA Container Toolkit 이 꼭 설치되어 있어야 한다.
--gpu=1 flag는 하나의 gpu가 inferencing 할 때 사용될 수 있다는 것을 의미한다.
$ docker run --gpus=1 --rm -p8000:8000 -p8001:8001 -p8002:8002 -v/full/path/to/docs/examples/model_repository:/models nvcr.io/nvidia/tritonserver:<xx.yy>-py3 tritonserver --model-repository=/models
triton을 실행하면 콘솔창에서 서버가 시작되고 모델을 불러오는 출력을 볼 수 있다.
아래와 같이 출력이 되었다면, triton은 inference 요청을 받아들일 준비가 되었다는 것이다.
+----------------------+---------+--------+
| Model | Version | Status |
+----------------------+---------+--------+
| <model_name> | <v> | READY |
| .. | . | .. |
| .. | . | .. |
+----------------------+---------+--------+
...
...
...
I1002 21:58:57.891440 62 grpc_server.cc:3914] Started GRPCInferenceService at 0.0.0.0:8001
I1002 21:58:57.893177 62 http_server.cc:2717] Started HTTPService at 0.0.0.0:8000
I1002 21:58:57.935518 62 http_server.cc:2736] Started Metrics Service at 0.0.0.0:8002
모든 모델이 "READY" 상태라면, 모델이 잘 불러져 왔다는 것을 의미한다.
만약 모델을 불러오는데 실패했다면, 실패라는 표시와 그 이유가 적힐 것이다.
만약 표에 있어야 할 모델이 표시되지 않았다면, model repository 의 path를 확인해보거나 CUDA drivers 을 확인해라.
Run on CPU-Only System
GPU가 없는 시스템에서는 --gpus flag 없이 도커를 실행시키면 된다.
나머지는 모두 위와 같다.
$ docker run --rm -p8000:8000 -p8001:8001 -p8002:8002 -v/full/path/to/docs/examples/model_repository:/models nvcr.io/nvidia/tritonserver:<xx.yy>-py3 tritonserver --model-repository=/models
gpu를 사용하지 않으므로, GPU를 요구하는 model configuration 이 불러와지지 않을 것이다.
Verify Triton Is Running Correctly
triton의 ready endpoint 를 사용하여 서버가 inference할 준비가 되었는지 확인할 수 있다.
host system에서 curl을 사용하여 서버의 상태를 표시하는 HTTP endpoint에 접근한다.
$ curl -v localhost:8000/v2/health/ready
...
< HTTP/1.1 200 OK
< Content-Length: 0
< Content-Type: text/plain
200을 return하면 준비가 된 것이고, 200이 아니라면 준비가 되지 않은 것이다.
Getting The Client Examples
docker pull을 사용하여, NGC에서 client libraries 와 예시 이미지를 가져온다.
docker run을 사용하여, client 이미지를 실행시킨다.
$ docker pull nvcr.io/nvidia/tritonserver:<xx.yy>-py3-sdk
$ docker run -it --rm --net=host nvcr.io/nvidia/tritonserver:<xx.yy>-py3-sdk
Running The Imae Classification Example
nvcr.io/nvidia/tritonserver:<xx.yy>-py3-sdk 이미지 안에서, example image-client application을 실행시켜 densenet-onnx 모델로 image classification을 수행한다.
/workspace/images 에 있는 이미지 파일을 사용하여, densenet_onnx 모델에 요청을 보낸다.
이 경우 top 3 classifications 를 요청한다.
$ /workspace/install/bin/image_client -m densenet_onnx -c 3 -s INCEPTION /workspace/images/mug.jpg
Request 0, batch size 1
Image '/workspace/images/mug.jpg':
15.346230 (504) = COFFEE MUG
13.224326 (968) = CUP
10.422965 (505) = COFFEEPOT
'Data Engineer > triton inference server' 카테고리의 다른 글
Triton Client (0) | 2021.06.29 |
---|---|
[ Server ] Model Repository (0) | 2021.06.29 |
[ Server ] Inference protocols (0) | 2021.06.28 |
[ Server ] build (0) | 2021.06.28 |
[ Server ] Model Analyzer (0) | 2021.06.28 |