Dmitry Lamanov
02/18/2024, 2:46 PMpredictions = await asyncio.gather(
*(self.generator_runner.async_run(
source_image,
kp_source_tensor,
kp_driving_tensor
) for kp_driving_tensor in kp_driving_tensors)
)
Here, source_image, kp_source_tensor, and kp_driving_tensor are batches of tensors.
The generator is a custom PyTorch model. The export to the Bento model looks like this:
bentoml.pytorch.save_model(
"sadtalker_generator", generator,
signatures={"__call__": {
"batchable": True, "batch_dim": 0
}}
)
When I initialise my service with generator runner it works x1.5 times slower comparing with to same code where generator_runner initialised locally or without wrapping generator with BentoML runner.
Initially, all tensors are on the same GPU as the generator model. From what I understand, a lot of time is wasted on data transfer, collecting it from the GPU, and copying it back to the same GPU or something wrong with asynchronous calls to the model runner. What would be the optimal solution for my case?