My flask app just stops when it starts loading my torch model

I have saved my Pytorch model as a state_dict, and am now trying to load it into flask for inference.
However when I run my flask API, it just stopped. And using my debugger got me here.

The same model loads in my notebook. Why is this happening? Any help would be great!

1 Like

you can check this Deploying PyTorch in Python via a REST API with Flask — PyTorch Tutorials 1.8.1+cu102 documentation

Hey, It doesn’t seem to be a code problem. The flask app used to work on my old system, but doesn’t on my new one. Same code in both places.

please provide more code in you and

this is from

from torch import nn 
import torch.nn.functional as F

class Model(nn.Module):
    def __init__(self):
        super(Model, self).__init__()
        self.linearA = nn.Linear(13,100)
        self.linearB = nn.Linear(100, 50)
        self.linearC = nn.Linear(50, 1)

    def forward(self, x):
        yA = F.relu(self.linearA(x))
        yB = F.relu(self.linearB(yA))
        return self.linearC(yB)

and this is the part from

data.model = Model()