This message was deleted.
# ask-for-help
s
This message was deleted.
s
Yes, they do, at least in production mode.
p
Copy code
import bentoml
from <http://bentoml.io|bentoml.io> import NumpyNdarray

model = bentoml.pytorch.get(
    'model:latest').to_runner()
svc = bentoml.Service(
    'shrimp-predictor', runners=[model])

@svc.api(input=NumpyNdarray(), output=NumpyNdarray())
async def func(data):
    for _ in range(100):
        await model.async_run(data)
    return data
Copy code
from torch import nn

class Net(nn.Module):
    def forward(self, x):
        print(f'Model input {x.shape}')
        return x
Copy code
import bentoml

bentoml.pytorch.save_model('model', Net(), signatures={'__call__': {'batchable': True, 'batch_dim': 0}})
Copy code
from bentoml.client import Client
import numpy as np

bento_client = Client.from_url('<http://localhost:7777>')
data = np.array([[1]])
bento_client.func(data)
Copy code
pyenv exec python -m bentoml serve --production draft:svc -p 7777
The shapes printed out are alwasy (1, 1)
s
It seems like you're trying to run await in a for loop; that will just run each request in series.
I think in python to run those tasks, you should use
create_task
instead, and then await those tasks.
p
It works. thank you!
s
Great, no problem!