Pyservicemaker and GIL

I read the documentation of Service Maker for Python and found one not clarified topic related to BufferOperator (here is link for ref)

Will BufferOperator instance acquire GIL?
If yes - does it mean that several instances of BufferOperator will block each other (by trying to acquire GIL)?
If not - How BufferOperator do this?

For the “BufferOperator” interface itself, it requires GIL.

If they handles the same buffer in different threads, they will block each other.

I thought that even if the buffers are different, they would still acquire the same GIL because the interpreter is the same. Am I correct?

Since the BufferOperator interface should be used with the pyservicemaker probe interfaces, the GIL is not needed with pyservicemaker.

Let’s refer to the docs example:

from pyservicemaker import BufferProvider, ColorFormat, as_tensor
import torch

class MyBufferProvider(BufferProvider):
    def generate(self, size):
        torch_tensor = torch.load('tensor_data.pt')
        ds_tensor = as_tensor(torch_tensor, "HWC")
        return ds_tensor.wrap(ColorFormat.RGB)

Here we have generate() function, which will acquire GIL.
So if we create several instances of MyBufferProvider, calls of their generate() functions will acquire the same GIL, so only one MyBufferProvider can work at the same time.
I don’t know pyservicemaker source code, but I doubt it releases GIL before generate() function calls.

How will you create several instances of MyBufferProvider? Why do you need to create several instances of MyBufferProvider?

For example, I will have several streams that should be processed by one trtengine.
Or if I will have BufferOperator and BufferRetriever in the pipeline for postprocessing and exporting data.

These streams will be handled in batch by service maker. Please refer to /opt/nvidia/deepstream/deepstream/service-maker/sources/apps/python/pipeline_app/deepstream_test3_app

BufferProvider and BufferRetriever are used with appsink and appsrc. Please refer to /opt/nvidia/deepstream/deepstream/service-maker/sources/apps/python/pipeline_api/deepstream_appsrc_test_app

1 Like

There is no update from you for a period, assuming this is not an issue anymore. Hence we are closing this topic. If need further support, please open a new one. Thanks

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.