Comments (4)
Hello @Seraph1990 !
If I understood you correctly, you would like to send a batch of images to the server. Generally there are two possible approaches, that we advice:
- Use
dynamic_batching
. To explain dynamic batching is out of scope of such short answer, I encourage you to read a very good tutorial about this in tritonserver repo. When using dynamic batching, the suggested solution is to send a single sample per request, therefore the code presented in the example you are referring to is sufficient. - Use
static_batching
. When you don't want to use dynamic batching, you need to put together a batch of images manually. This example shows what you need to do, please refer there. In this approach we recommend sending encoded JPEGs. You should put together a batch of encoded JPEGs - every sample will have different length, but all of them will be 1-dimensional. Simply pad all samples to the size of the longest buffer with zeros, e.g.
batch:
sample 1: [3 4 1 3 5 0 0 0] <-- padded three zeros
sample 2: [3 5 6 2 1 3 5 6]
sample 3: [3 4 4 6 7 4 3 0] <-- padded one zero
Please remember, that sending decoded images with static batching is generally bad idea and should be avoided. The reasons are: problems with different image sizes in a single batch (that’s not supported in Triton), not leveraging DALI’s decoding, enlarging network load and many more. As I said before, we recommend using encoded JPEGs with static batching.
Please refer also to similar questions: NVIDIA/DALI#3234. Should you have any more questions, don't hesitate to ask!
from dali_backend.
@szalpal If use dynamic_batching
, the server itself is going to combine the samples sent into a batch. How did it do it?Is it similar to your pad method?
Another question: Can dynamic_batching
and static_batching
be used together? If not. In terms of performance, which method is recommended?
Thank you!
from dali_backend.
If use dynamic_batching, the server itself is going to combine the samples sent into a batch. How did it do it?Is it similar to your pad method?
Yes, the server combines the batch. It's not really similar to pad method - server will just put together samples of the same shape into a batch (or the max delay time is exceeded).
Can
dynamic_batching
andstatic_batching
be used together? If not. In terms of performance, which method is recommended?
They can't be used together. Unfortunately for the performance question, the answer is "it depends". It's hard to formulate a general rule, but you can start with "static_batching
is better for optimizing throughput, while dynamic_batching
- latency".
Everything depends on your use-case. E.g. if you design a conversational-AI system, the typical inference scenario would be to send chunks of audio data, where at the beginning of user's utterance there will be less data sent, so the server can start the processing while the user is still speaking. Therefore in this case dynamic batching is the way to go. However when you have a CCTV system, where you record users and identify them with face recognition, your bigger concern would be the throughput, not the latency. Therefore it would be better to use static batching.
It's nearly always a matter of empirical check, which way suits you most. This section in Triton docs shows a one of possible ways to optimize the dynamic vs static batching.
from dali_backend.
@szalpal Thank you very much ! In addition, based on static batching
method, I found another way to load multiple encoded images: change the input to TYPE_STRING. Because the length of TYPE_STRING is not fixed.
from dali_backend.
Related Issues (20)
- Batching does not improve performance with dali HOT 10
- Can dali backend support default values or optional input? HOT 2
- Unexpected large memory needed for gpu resize HOT 4
- Error in thread 31: nvJPEG error (5): The user-provided allocator functions, for either memory allocation or for releasing the memory, returned a non-zero code. HOT 6
- Cannot compile dali_backend with older version of triton HOT 2
- how to provide batch input data for dali pipeline whicn input shapes [-1] HOT 1
- if I want to crop from different start point, how can I build pipe to do this? HOT 2
- Test issue
- Connecting InputOperator with no explicit inputs to Triton HOT 12
- Could not serialize dali.fn.python_function HOT 1
- when using crop_mirror_normalize func, Output layout "CHW" is slower than "HWC" HOT 5
- dlopen libcuda.so failed!. Please install GPU dirverTraceback (most recent call last): HOT 4
- Prefeed multiple input batches to the inference pipeline HOT 7
- Unable to load numpy module in a DALI backend HOT 3
- DALI pipeline in Triton - formatting InferInput batch of images for UINT8 HOT 3
- 'NoneType' object has no attribute 'loader' when trying to load DALI model. HOT 11
- How to format client code for inception example HOT 14
- How to get list of image paths into dali pipeline? HOT 4
- How to use scalar inputs HOT 3
- Video Input larger than max
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dali_backend.