|
| 1 | +# Tritonbackend Usage |
| 2 | + |
| 3 | +## How To Use Tritonbackend |
| 4 | + |
| 5 | +### How To Compile Tritonbackend |
| 6 | + |
| 7 | +- Execute commands as below |
| 8 | + |
| 9 | + ``` |
| 10 | + $ cd <lightseq_repository> |
| 11 | + $ mkdir build && cd build && \ |
| 12 | + cmake -DCMAKE_BUILD_TYPE=Release -DFP16_MODE=ON -DDEBUG_MODE=OFF -DDYNAMIC_API=ON .. && \ |
| 13 | + make -j${nproc} |
| 14 | + ``` |
| 15 | + |
| 16 | + Then you can get outcomes include `libliblightseq.so` and `libtriton_lightseq.so`, Which are needed by model repository. |
| 17 | + |
| 18 | + You can find libliblightseq.so in this path |
| 19 | + |
| 20 | + `<lightseq_repository>/build/lightseq/inference/pywrapper/libliblightseq.so` |
| 21 | + |
| 22 | + While libtriton_lightseq.so is in |
| 23 | + |
| 24 | + `<lightseq_repository>/build/lightseq/inference/triton_backend/libtriton_lightseq.so` |
| 25 | + |
| 26 | +### How To Organize Model Repository |
| 27 | + |
| 28 | +``` |
| 29 | +├── <path_to_model_repository>/ |
| 30 | +│ ├── libliblightseq.so # dynamic link library of lightseq, which contains the almost |
| 31 | +│ │ implement of lightseq, and should be included by LD_LIBRARY_PATH |
| 32 | +│ ├── <model_name_1>/ # the directory of model, include parameters and configurations. |
| 33 | +│ │ ├── config.pbtxt # the config of model, more detail is as below. |
| 34 | +│ │ ├── <model_file> # the file of model parameters. |
| 35 | +│ │ ├── 1/ # this empty directory is necessary, which is needed by tritonserver. |
| 36 | +│ │ ├── libtriton_lightseq.so # dynamic link library of lightseq's tritonbackend |
| 37 | +│ ├── <model_name_2>/ # ... |
| 38 | +│ │ ├── config.pbtxt # ... |
| 39 | +│ │ ├── <model_file> # ... |
| 40 | +│ │ ├── 1/ # ... |
| 41 | +│ │ ├── libtriton_lightseq.so # ... |
| 42 | +│ ├── #<model_name_vid>... # more models etc... |
| 43 | +``` |
| 44 | + |
| 45 | +- The meaning of parameters in config.pbtxt, more information you can find in [Model config of tritonbackend](https://github.com/triton-inference-server/common/blob/main/protobuf/model_config.proto) |
| 46 | + |
| 47 | + > ${name}: name of model,**which should be same with <model_name_vid>** |
| 48 | + > |
| 49 | + > ${backend}: **fixed value - "lightseq"**,which is used to recognize the dynamic link library of tritonbackend, libtriton_lightseq.so |
| 50 | + > |
| 51 | + > ${default_model_filename}: name of model file,**which should be same with <model_file>** |
| 52 | + > |
| 53 | + > ${parameters - value - string_value}: the type of model, which should be supported by lightseq. You can choose `Transformer`|`QuantTransformer`|`Bert`|`Gpt`|`Moe` |
| 54 | +
|
| 55 | +- You can see example in [Example Of Triton Model Config](https://github.com/bytedance/lightseq/tree/master/examples/triton_backend/model_repo), while you can also find more detailed information in [Model Config Of Tritonserver](https://github.com/triton-inference-server/server/blob/main/docs/model_configuration.md). |
| 56 | + |
| 57 | + - The model files which needed by [Example Of Triton Model Config](https://github.com/bytedance/lightseq/tree/master/examples/triton_backend/model_repo) you can find in [The Guide of Model Export](https://github.com/bytedance/lightseq/blob/master/examples/inference/python/README.md). |
| 58 | + |
| 59 | +### How To Run Tritonserver |
| 60 | + |
| 61 | +#### Run Tritonserver By Docker |
| 62 | + |
| 63 | +- Get tritonserver Docker: [Tritonserver Quickstart](https://github.com/triton-inference-server/server/blob/main/docs/quickstart.md#install-triton-docker-image) |
| 64 | + |
| 65 | + ``` |
| 66 | + $ sudo docker pull nvcr.io/nvidia/tritonserver:22.01-py3 |
| 67 | + ``` |
| 68 | + |
| 69 | +- Docker Commands: |
| 70 | + |
| 71 | + ``` |
| 72 | + $ sudo docker run --gpus=<num_of_gpus> --rm -e LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/models" -p8000:8000 -p8001:8001 -p8002:8002 -v<model_repository>:/models nvcr.io/nvidia/tritonserver:22.01-py3 tritonserver --model-repository=/models |
| 73 | + ``` |
| 74 | + |
| 75 | + - <num_of_gpus>: int, the number of gpus which are needed by tritonserver. |
| 76 | + |
| 77 | + - <model_repository>: str, the path of model repository which are organized by yourself. |
| 78 | + |
| 79 | +- Install client requirements: |
| 80 | + |
| 81 | + ``` |
| 82 | + $ pip install tritonclient[all] |
| 83 | + ``` |
| 84 | + |
| 85 | +## Reference |
| 86 | + |
| 87 | +- [triton-inference-server/backend](https://github.com/triton-inference-server/backend) |
| 88 | +- [triton-inference-server/server](https://github.com/triton-inference-server/server) |
| 89 | +- [triton-inference-server/client](https://github.com/triton-inference-server/client) |
| 90 | +- [triton-inference-server/core](https://github.com/triton-inference-server/core) |
| 91 | +- [triton-inference-server/common](https://github.com/triton-inference-server/common) |
0 commit comments