-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
[blockChooser.cpp::getRegionBlockSize::690] Error Code 2: Internal Error (Assertion memSize >= 0 failed. ) #2045
Comments
I can avoid the above error by replacing x_t = torch.zeros((B, C, H + pad_h, W + pad_w), device=x.device)
x_t[:, :, :H, :W] = x
return x_t to x = torch.cat((x, torch.zeros((B, C, pad_h, W), device=x.device)), 2)
x = torch.cat(
(x, torch.zeros((B, C, x.shape[-2], pad_w), device=x.device)), -1)
return x However, if I put another shape transformation line before x = torch.cat((x, torch.zeros((B, C, pad_h, W), device=x.device)), 2)
x = torch.cat(
(x, torch.zeros((B, C, x.shape[-2], pad_w), device=x.device)), -1)
x = x.reshape(-1, x.shape[1], x.shape[2] * x.shape[3])
return x |
but there is one problem here, TensorRT doesn't support the mod operator. does your model has an unknown H and W during inference? |
Yes, just want to do dynamic inference. It is actually used in swin-transformer. |
Looks like there is no way we can avoid the mod operator here, how about making the pad_w and pad_h also the network inputs? and computing it outside the network. |
Well, it is hard to control the input |
So, if the mod operator raises the error, maybe writing a plugin is the workaround? Just want to make sure if the mod operator raises it. And if I include the mod part inside the plugin, there should be no shape-related issue then? |
Yes, plugin should work. |
Hi, @zerollzeng. I tried another way to avoid the mod operator here: class NaiveModel(torch.nn.Module):
def __init__(self):
super().__init__()
def forward(self, x):
B, C, H, W = x.shape
pad_h = H - (H // 7) * 7
x = torch.cat((x, torch.zeros((B, C, pad_h, W), device=x.device)), 2)
x = x.reshape(-1, x.shape[1], x.shape[2] * x.shape[3])
return x But again the above error was triggered. |
How about
will it work? |
It failed. Besides, it is not padding failed as I mentioned above. Only padding can be converted to TRT while it failed once we append another reshape. |
Yes,
I can see the error
|
A workaround is to replace the reshape in prepare_onnx_paddings with the Concat of two Slice with step=2 (begins and ends) of paddings. # paddings = sym_help._reshape_helper(
# g, paddings, g.op("Constant", value_t=torch.tensor([-1, 2])))
# paddings = g.op(
# "Transpose",
# torch.onnx.symbolic_opset10.flip(g, paddings, [0]),
# perm_i=[1, 0])
# paddings = sym_help._reshape_helper(
# g, paddings, g.op("Constant", value_t=torch.tensor([-1])))
paddings = torch.onnx.symbolic_opset10.flip(g, paddings, [0])
begins = sym_help._slice_helper(
g, paddings, axes=[0], starts=[1], ends=[0xffff], steps=[2])
ends = sym_help._slice_helper(
g, paddings, axes=[0], starts=[0], ends=[0xffff], steps=[2])
paddings = g.op('Concat', begins, ends, axis_i=0) |
ND shape tensor will be supported in the next version after TRT 8.4. |
Closing since no activity for more than 3 weeks, please reopen if you still have question, thanks! |
Description
Encounter the error as follows:
Environment
TensorRT Version: 8+
NVIDIA GPU: 1660
NVIDIA Driver Version: 470
CUDA Version: 11.3
CUDNN Version: compatible with cuda 11.3
Operating System: linux x86
Python Version (if applicable): 3.8
PyTorch Version (if applicable): 1.10
Steps To Reproduce
The text was updated successfully, but these errors were encountered: