我正在尝试提取VGG16模型中最后一层的激活。 为此,我在模型上使用了一个装饰器,如下所示。
当我将cuda张量传递给模型时,我得到一个带有以下回溯的CUDNN_STATUS_INTERNAL_ERROR。
任何人都知道我哪里出错了?
回溯:
File "/media/data1/iftachg/frame_glimpses/parse_files_to_vgg.py", line 80, in get_activation
return model(image)
File "/media/data1/iftachg/miniconda2/lib/python2.7/site-packages/torch/nn/modules/module.py", line 206, in __call__
result = self.forward(*input, **kwargs)
File "/media/data1/iftachg/frame_glimpses/partial_vgg.py", line 24, in forward
x = self.vgg16.features(x)
File "/media/data1/iftachg/miniconda2/lib/python2.7/site-packages/torch/nn/modules/module.py", line 206, in __call__
result = self.forward(*input, **kwargs)
File "/media/data1/iftachg/miniconda2/lib/python2.7/site-packages/torch/nn/modules/container.py", line 64, in forward
input = module(input)
File "/media/data1/iftachg/miniconda2/lib/python2.7/site-packages/torch/nn/modules/module.py", line 206, in __call__
result = self.forward(*input, **kwargs)
File "/media/data1/iftachg/miniconda2/lib/python2.7/site-packages/torch/nn/modules/conv.py", line 237, in forward
self.padding, self.dilation, self.groups)
File "/media/data1/iftachg/miniconda2/lib/python2.7/site-packages/torch/nn/functional.py", line 39, in conv2d
return f(input, weight, bias)
RuntimeError: CUDNN_STATUS_INTERNAL_ERROR
类:
class partial_vgg(nn.Module):
def __init__(self):
super(partial_vgg, self).__init__()
self.vgg16 = models.vgg16(pretrained=True).cuda()
for param in self.vgg16.parameters():
param.requires_grad = False
def forward(self, x):
x = self.vgg16.features(x)
x = x.view(x.size(0), -1)
for l in list(self.vgg16.classifier.children())[:-3]:
x = l(x)
return x
答案 0 :(得分:1)
显然,cudnn错误非常无用,代码本身也没有问题 - 它只是我试图访问的GPU已经在使用中。
答案 1 :(得分:1)
这看起来像一个张量塑形bug。如上所述,CUDNN错误消息几乎无用。要获得更直观的错误消息,请在CPU上运行代码。
net.cpu()