Upon running the following code snippet,
class CNN_NER(nn.Module): 
    def __init__(self,vocab_size,embedding_size):
        # vocab_size, embedding_size, window_size, hidden_size, output_size

        super(CNN_NER, self).__init__()
        
        self.embed = nn.Embedding(vocab_size, embedding_size)
        self.cnn1 = nn.Conv2d(in_channels=1,padding=2,out_channels=100,kernel_size=(11,54),stride=1,dilation=1)
        self.cnn2 = nn.Conv2d(in_channels=1,padding=2,out_channels=100,kernel_size=(10,54),stride=1,dilation=1)
        self.cnn3 = nn.Conv2d(in_channels=1,padding=2,out_channels=100,kernel_size=(9,54),stride=1,dilation=1)
        
        self.relu = nn.ReLU()
        self.maxpool3 = nn.MaxPool2d(kernel_size=(1,3))
        self.maxpool4 = nn.MaxPool2d(kernel_size=(1,4))
        self.maxpool5 = nn.MaxPool2d(kernel_size=(1,5))
        self.linear = nn.Linear(60,9)
#        self.dropout = nn.Dropout(0.2)
        
    def forward(self,sent_grams,is_training):
        embeds = self.embed(sent_grams)
        embeds = embeds.unsqueeze(1)
        print('inputs',embeds.size())
        l1 = self.cnn1(embeds)
        l1 = self.relu(l1)
        print('cnn1',l1.size())
        l1 = l1.squeeze(3)
        l1 = self.maxpool3(l1)
        print('maxpool3',l1.size())
        l2 = self.cnn2(embeds)
        l2 = self.relu(l2)
        print('cnn2',l1.size())
        l2 = l2.squeeze(3)
        l2 = self.maxpool4(l2)
        print('maxpool4',l2.size())
        l3 = self.cnn3(embeds)
        l3 = self.relu(l3)
        print('cnn3',l1.size())
        l3 = l3.squeeze(3)
        l3 = self.maxpool5(l3)
        print('maxpool5',l3.size())
        
        l4 = torch.cat((l1,l2,l3),1)
        print('concatenated',l4.size())
        l4 = l4.view(l4.size(0),5,60)
        print('quished before linear layer',l4.size())
        l5 = self.linear(l4)
        print('output',l5.size())
        return l5

model = CNN_NER(len(word2index), EMBEDDING_SIZE)
model.cuda()

I get the cuda  error below:


RuntimeError                              Traceback (most recent call last)
 in ()
5 LEARNING_RATE = 0.001
6 model = CNN_NER(len(word2index), EMBEDDING_SIZE)
----> 7 model.cuda()
8 # Visualize the model paramters
9 for name,params in model.named_parameters():
/opt/anaconda3/lib/python3.6/site-packages/torch/nn/modules/module.py in cuda(self, device)
256             Module: self
257         “”"
–> 258         return self._apply(lambda t: t.cuda(device))
259
260     def cpu(self):
/opt/anaconda3/lib/python3.6/site-packages/torch/nn/modules/module.py in _apply(self, fn)
183     def _apply(self, fn):
184         for module in self.children():
–> 185             module._apply(fn)
186
187         for param in self._parameters.values():
/opt/anaconda3/lib/python3.6/site-packages/torch/nn/modules/module.py in _apply(self, fn)
189                 # Tensors stored in modules are graph leaves, and we don’t
190                 # want to create copy nodes, so we have to unpack the data.
–> 191                 param.data = fn(param.data)
192                 if param._grad is not None:
193                     param._grad.data = fn(param._grad.data)
/opt/anaconda3/lib/python3.6/site-packages/torch/nn/modules/module.py in (t)
256             Module: self
257         “”"
–> 258         return self._apply(lambda t: t.cuda(device))
259
260     def cpu(self):
RuntimeError: cuda runtime error (59) : device-side assert triggered at /opt/conda/conda-bld/pytorch_1535491974311/work/aten/src/THC/generic/THCTensorCopy.cpp:20

Am unable to comprehend the same. Any help would be much appreciated!