NVIDIA-AI-IOT / torch2trt

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

Using GroupNorm: 'ImportError: cannot import name 'GroupNormPlugin' from 'torch2trt.plugins' (unknown location)' #683

Open littlespice opened 2 years ago

littlespice commented 2 years ago

Hi,

I'm trying to use torch2trt for nn.GroupNorm layer. When I run my toy model with torch2trt, it outputs the following error:

import torch
import torch.nn as nn
from torch2trt import torch2trt
gn_model = nn.GroupNorm(6).eval.().cuda()
input = torch.randn(20, 6, 10, 10).cuda()
trt_gn_model = torch2trt(gn_model, [input])

ImportError: cannot import name 'GroupNormPlugin' from 'torch2trt.plugins' (unknown location)

torch2trt has been installed without error using:

python setup.py install --plugins

Does anyone know what might have caused this import error? Replication of this error case or possible measures would be greatly appreciated. Thanks in advance!

kct22aws commented 2 years ago

Any fix yet? I am running into this error as well.

littlespice commented 2 years ago

Judging by the plugin description here with interpolate only, I assumed GroupNorm support is not yet fully complete. Ended up implementing my own GroupNorm layer that works with torch2trt.

kct22aws commented 2 years ago

@littlespice Would you mind sharing it?