This message was deleted.
# ask-for-help
s
This message was deleted.
j
Hey! Welcome to BentoML, how can we help
d
On the page that I linked, I am specifically following the instructions under heading: Pre-built Model Runners. When I run this code I get an error that states: AttributeError: 'Model' object has no attribute 'predict'
j
can you share the code that you are running?
this means the pytorch model that you are building does not have the
predict
function
Because I am using the forward method to make predictions?
what is the best way for me to proceed so I can make predictions?
j
you can simply run
runner.predict.run(..)
. this is analogous to doing
model(..)
or
await runner.async_run(..)
if you want to run the prediction asynchornously
d
runner = bentoml.pytorch.get("pytorch_model:xzrlgzsovglrsycf").to_runner() runner.init_local() print(runner.predict.run([[133.171875, 59.716081, 0.043133, -0.703383, 54.917224, 70.084438, 0.749798, -0.649512]]))
j
SORRY
i mean
runner.run(..)
without the predict word
d
for some reason that is still not working. do you think it has to do with how I saved my model? should I save it like:
Copy code
bentoml.pytorch.save(
    model,
    "my_torch_model",
    signatures={"__call__": {"batchable": True, "batch_dim": 0}},
)
instead of like:
Copy code
bentoml.pytorch.save_model(
    "demo_mnist",  # model name in the local model store
    trained_model,  # model instance being saved
    signatures={   # model signatures for runner inference
        "predict": {
            "batchable": True,
            "batch_dim": 0,
        }
    }
)
j
you are right,
Copy code
signatures={   # model signatures for runner inference
        "predict": {
            "batchable": True,
            "batch_dim": 0,
        }
    }
this expects a
predict
function in your model. for pytorch model you could see this page https://docs.bentoml.org/en/latest/frameworks/pytorch.html
d
I appreciate your help!!!!
I was so confused so thank you for helping me figure out the problem.
j
you're welcome! this also points out that we probably need to more clear in our documentation!
👍 1