Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
luhang-HPU opened this issue May 23, 2020 · 8 comments

Comments

@luhang-HPU
Copy link

luhang-HPU commented May 23, 2020

I implement a very simple network and try to convert it using torch2trt:

class Net(nn.Module):
    def __init__(self):
        super(Net, self).__init__()
        self.conv1 = nn.Conv2d(1, 64, (5, 5), (1, 1), (2, 2))
        self.conv2 = nn.Conv2d(64, 32, (3, 3), (1, 1), (1, 1))
        ...... #omitted
    def forward(self, x):
        x = F.tanh(self.conv1(x))
        x = F.tanh(self.conv2(x))
        ......

I only use two conv2d layers and nothing else.
The conversion code is like:

   model.load_state_dict(torch.load('epochs/' + MODEL_NAME))
    x = torch.randn([1, 1, 270, 480]).cuda()
   model_trt = torch2trt(model, [x], fp16_mode=True)

Simple, right?

When I use the model:

out = model_trt(image)
print(out.size())

it gives me this fucking error. I check the dimensions of "out", and it shows:
torch.Size([1, 1, 1, 2160, 3840])
If I do not convert the model, it works just fine, by giving:
torch.Size([1, 1, 2160, 3840]), which is the target output I want.

I cannot just figure out why such simple code cannot be converted, and I do not know what this error means.

I use ubuntu18.04 cuda10.2, cudnn7.6.5 with trt 7.0.11, and the lateset torch2trt with plugin. ``

@luhang-HPU
Copy link
Author

I have an unsupported layer called: pixel_shuffle in my model, and I think it causes the problem:
Warning: Encountered known unsupported method torch.nn.functional.pixel_shuffle
If I comment out this layer, torch2trt works fine. It seems that this layer has added an extra dimension.
Then, the problem is how I can live this unsupported layer?

@czs1886
Copy link

czs1886 commented Jun 16, 2020

I have an unsupported layer called: pixel_shuffle in my model, and I think it causes the problem:
Warning: Encountered known unsupported method torch.nn.functional.pixel_shuffle
If I comment out this layer, torch2trt works fine. It seems that this layer has added an extra dimension.
Then, the problem is how I can live this unsupported layer?

I think you need to write some converters for those unsupported layers.

@luhang-HPU
Copy link
Author

I have an unsupported layer called: pixel_shuffle in my model, and I think it causes the problem:
Warning: Encountered known unsupported method torch.nn.functional.pixel_shuffle
If I comment out this layer, torch2trt works fine. It seems that this layer has added an extra dimension.
Then, the problem is how I can live this unsupported layer?

I think you need to write some converters for those unsupported layers.

Thanks for the reply. I think you are right. I tried to use a custom plugin for this op but still does not work out. Do you know any easy way to create a custom plugin within torch2trt?

@czs1886
Copy link

czs1886 commented Jun 28, 2020

@hive-cas
There are some tensorRT functions to be used and you can check the [official doc] for more details (https://docs.nvidia.com/deeplearning/tensorrt/api/c_api/classnvinfer1_1_1_i_network_definition.html)

Just look at the converters torch2trt implements and create a custom plugin your own.

@PressEtoRace
Copy link

I have an unsupported layer called: pixel_shuffle in my model, and I think it causes the problem:
Warning: Encountered known unsupported method torch.nn.functional.pixel_shuffle
If I comment out this layer, torch2trt works fine. It seems that this layer has added an extra dimension.
Then, the problem is how I can live this unsupported layer?

I think you need to write some converters for those unsupported layers.

Thanks for the reply. I think you are right. I tried to use a custom plugin for this op but still does not work out. Do you know any easy way to create a custom plugin within torch2trt?

Hi hive-cas, have you successfully converted pixel_shuffle?

@luhang-HPU
Copy link
Author

I have an unsupported layer called: pixel_shuffle in my model, and I think it causes the problem:
Warning: Encountered known unsupported method torch.nn.functional.pixel_shuffle
If I comment out this layer, torch2trt works fine. It seems that this layer has added an extra dimension.
Then, the problem is how I can live this unsupported layer?

I think you need to write some converters for those unsupported layers.

Thanks for the reply. I think you are right. I tried to use a custom plugin for this op but still does not work out. Do you know any easy way to create a custom plugin within torch2trt?

Hi hive-cas, have you successfully converted pixel_shuffle?

Sadly. Still no. There are too many errors I cannot figure out.

@wwdok
Copy link

wwdok commented Feb 4, 2021

I am facing the same issue, i joined the comment ~

@owoshch
Copy link

owoshch commented Aug 16, 2021

@hive-cas Hi! I have faced the same problem with pixel_shuffle layer in my network. Have you found the ready-to-use solution for this layer?

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants