InternImage
InternImage copied to clipboard
RuntimeError: Not implemented on the CPU
First, I successfully compiled DCNv3, but an error occurred when I performed inference and training! The following is the error that occurs.
File "D:\project(yolo)\_DCNv3\functions\dcnv3_func.py", line 39, in forward
output = DCNv3.dcnv3_forward(
RuntimeError: Not implemented on the CPU
DCNv3Function function in dcnv3_func.py
class DCNv3Function(Function):
@staticmethod
@custom_fwd
def forward(
ctx, input, offset, mask,
kernel_h, kernel_w, stride_h, stride_w,
pad_h, pad_w, dilation_h, dilation_w,
group, group_channels, offset_scale, im2col_step):
ctx.kernel_h = kernel_h
ctx.kernel_w = kernel_w
ctx.stride_h = stride_h
ctx.stride_w = stride_w
ctx.pad_h = pad_h
ctx.pad_w = pad_w
ctx.dilation_h = dilation_h
ctx.dilation_w = dilation_w
ctx.group = group
ctx.group_channels = group_channels
ctx.offset_scale = offset_scale
ctx.im2col_step = im2col_step
output = DCNv3.dcnv3_forward(
input, offset, mask, kernel_h,
kernel_w, stride_h, stride_w, pad_h,
pad_w, dilation_h, dilation_w, group,
group_channels, offset_scale, ctx.im2col_step)
ctx.save_for_backward(input, offset, mask)
return output
This is the model I defined.
class DCNV3_YoLo(nn.Module):
def __init__(self, inc, ouc, k=1, s=1, p=None, g=1, act=True):
super().__init__()
self.conv = Conv(inc, ouc, k=1)
self.dcnv3 = DCNv3(ouc, kernel_size=k, stride=s, group=g)
# self.dcnv3 = DCNv3(ouc, kernel_size=k, stride=s, group=g)
self.bn = nn.BatchNorm2d(ouc)
# self.act = nn.SiLU() if act is True else (act if isinstance(act, nn.Module) else nn.Identity())
self.act = Conv.default_act
def forward(self, x):
x = x
x = self.conv(x)
x = x.permute(0, 2, 3, 1)
x = self.dcnv3(x)
x = x.permute(0, 3, 1, 2)
x = self.act(self.bn(x))
return x
First, I successfully compiled DCNv3, but an error occurred when I performed inference and training! The following is the error that occurs.
File "D:\project(yolo)\_DCNv3\functions\dcnv3_func.py", line 39, in forward output = DCNv3.dcnv3_forward( RuntimeError: Not implemented on the CPU
DCNv3Function function in dcnv3_func.py
class DCNv3Function(Function): @staticmethod @custom_fwd def forward( ctx, input, offset, mask, kernel_h, kernel_w, stride_h, stride_w, pad_h, pad_w, dilation_h, dilation_w, group, group_channels, offset_scale, im2col_step): ctx.kernel_h = kernel_h ctx.kernel_w = kernel_w ctx.stride_h = stride_h ctx.stride_w = stride_w ctx.pad_h = pad_h ctx.pad_w = pad_w ctx.dilation_h = dilation_h ctx.dilation_w = dilation_w ctx.group = group ctx.group_channels = group_channels ctx.offset_scale = offset_scale ctx.im2col_step = im2col_step output = DCNv3.dcnv3_forward( input, offset, mask, kernel_h, kernel_w, stride_h, stride_w, pad_h, pad_w, dilation_h, dilation_w, group, group_channels, offset_scale, ctx.im2col_step) ctx.save_for_backward(input, offset, mask) return output
This is the model I defined.
class DCNV3_YoLo(nn.Module): def __init__(self, inc, ouc, k=1, s=1, p=None, g=1, act=True): super().__init__() self.conv = Conv(inc, ouc, k=1) self.dcnv3 = DCNv3(ouc, kernel_size=k, stride=s, group=g) # self.dcnv3 = DCNv3(ouc, kernel_size=k, stride=s, group=g) self.bn = nn.BatchNorm2d(ouc) # self.act = nn.SiLU() if act is True else (act if isinstance(act, nn.Module) else nn.Identity()) self.act = Conv.default_act def forward(self, x): x = x x = self.conv(x) x = x.permute(0, 2, 3, 1) x = self.dcnv3(x) x = x.permute(0, 3, 1, 2) x = self.act(self.bn(x)) return x
这个问题我也遇到了,请问你解决了吗?
I also meet this problem!!!!!! If u has solved it, could u give me some suggestions
请问你是替换了yolo的backbone吗?