Is there a best example of multithreading or WebApi?
threerog opened this issue · 1 comments
threerog commented
Is YoloV8
object thread safe?
As is well known, it is very time-consuming to load the model for the first time. How to efficiently use YoloV8
when making concurrent calls in the form of multithreading or WebApi
?
Can you provide some relevant examples or solutions?
For example, is it feasible to use lock
or singleton
patterns
dme-compunet commented
The internal logic of YoloV8 should be thread safe, however GPUs sometimes cannot perform inference in parallel, for this there is the property YoloV8parameters.SuppressParallelInference
which when it is set to true
the inference is performed inside a lock block, the preprocess and postprocess will still work in parallel to speed up the results.