Hi!,
I face a problem using pytorch 1.3.0 on Cuda V100. Here the code originating from
and associated paper https://arxiv.org/pdf/1608.03981.pdf
class DnCNN(nn.Module):
def __init__(self, depth=17, n_channels=64, image_channels=1, use_bnorm=True, kernel_size=3):
super(DnCNN, self).__init__()
kernel_size = 3
padding = 1
layers = []
layers.append(nn.Conv2d(in_channels=image_channels, out_channels=n_channels, kernel_size=kernel_size, padding=padding, bias=True))
layers.append(nn.ReLU(inplace=True))
for _ in range(depth-2):
layers.append(nn.Conv2d(in_channels=n_channels, out_channels=n_channels, kernel_size=kernel_size, padding=padding, bias=False))
layers.append(nn.BatchNorm2d(n_channels, eps=0.0001, momentum = 0.95))
layers.append(nn.ReLU(inplace=True))
layers.append(nn.Conv2d(in_channels=n_channels, out_channels=image_channels, kernel_size=kernel_size, padding=padding, bias=False))
self.dncnn = nn.Sequential(*layers)
self._initialize_weights()
print("DnCNN init done")
def forward(self, x):
y = x
out = self.dncnn(x)
return y-out
def _initialize_weights(self):
for m in self.modules():
if isinstance(m, nn.Conv2d):
print('Conv init weight...',m.weight.size())
init.orthogonal_(m.weight)
print('Ok')
if m.bias is not None:
print('Conv init bias...')
init.constant_(m.bias, 0)
print('Ok')
elif isinstance(m, nn.BatchNorm2d):
print('BN init weight...')
init.constant_(m.weight, 1)
print('BN init bias...')
init.constant_(m.bias, 0)
print('Ok')
Use device…: cuda
Conv init weight… torch.Size([64, 1, 3, 3])
Ok
m.bias= Parameter containing:
tensor([-0.2753, 0.0797, -0.0850, -0.0789, -0.1403, 0.2473, 0.2015, -0.2147,
-0.1405, -0.1591, -0.0177, 0.2169, 0.3185, -0.2955, -0.3116, 0.1439,
0.2683, 0.2349, 0.2002, -0.0572, 0.2871, 0.1560, -0.2910, 0.1999,
0.2363, -0.0208, -0.0093, -0.2994, 0.1569, -0.0401, -0.3037, -0.2558,
-0.3046, -0.2971, 0.1851, 0.1453, -0.1999, 0.1158, 0.2158, -0.2221,
0.0930, 0.3183, -0.1261, -0.0886, -0.1297, 0.0019, 0.0564, -0.0134,
0.1727, 0.0585, 0.1753, -0.2736, 0.0683, 0.1069, -0.0181, 0.0422,
-0.2124, -0.1882, -0.1084, 0.2899, 0.1648, 0.1981, -0.0342, -0.1585],
requires_grad=True)
Conv init bias…
Ok
Conv init weight… torch.Size([64, 64, 3, 3])
Segmentation fault
So, the Segmentation fault is rised by the second Conv2d layer. Any idea?