NVIDIA-AI-IOT / torch2trt

An easy to use PyTorch to TensorRT converter
MIT License
4.58k stars 675 forks source link

[TensorRT] ERROR: INVALID_ARGUMENT: Cannot find binding of given name: input_0 #228

Open niuniu1988 opened 4 years ago

niuniu1988 commented 4 years ago

net forward code

def forward(self, X):
    N = X.size()[0]
    X = self.features(X)  # extract features

    X = X.view(N, 512, 1 ** 2)
    X = torch.bmm(X, torch.transpose(X, 1, 2)) / (1 ** 2)  

    X = X.view(N, 512 ** 2)
    X = torch.sqrt(X + 1e-5)
    X = torch.nn.functional.normalize(X)
    X = self.fc(X)

    assert X.size() == (N, self._num_cls)
    return X

convert pytorch to trt

net = Classifier().eval().cuda() net.load_state_dict(torch.load(model_path))

x = torch.ones(batch_size, 3, 224, 224).cuda() model_trt = torch2trt(net, [x])

show error

Warning: Encountered known unsupported method torch.bmm [TensorRT] ERROR: INVALID_ARGUMENT: Cannot find binding of given name: input_0

when use the model_trt, the prediction is always the same, no matter what is the label of the image. how to solve this problem?

ma-siddiqui commented 4 years ago

Hi, Any resolution?

PistonY commented 4 years ago

I have same issue, prediction is always the same. Any one solve this?

ma-siddiqui commented 4 years ago

same issue I faced. It seems the tensor/scalar values are treated as constant at some layers. need to implement converters for those layers.

ichangchangchang commented 3 years ago

do you have some resolutions?

ykk648 commented 3 years ago

may caused by some unsupport layers, finally I gave up torch2trt and chase onnx