I tried running with gdb as you’ve advised above, but when running backtrace, I get
(gdb) backtrace
No stack.

I’ve tried to reproduce the issue using a self-contained cross-entropy example (see below), but this runs without error.
import torch
from torch.autograd import Variable
import torch.nn as nn
import torch.nn.functional as F

class net(nn.Module):
    def __init__(self):
        nn.Module.__init__(self)
        self.conv = nn.Conv2d(3,31,1,2,1)
        self.avg_pool = nn.AvgPool2d((7,7), stride=(7,7))
        self._num_classes = 31

    def forward(self, X):
        X = self.conv(X)
        cls_score = self.avg_pool(X).squeeze()
        labels = Variable(torch.LongTensor(256,1).cuda().bernoulli_().squeeze())
        cross_entropy = F.cross_entropy(cls_score.view(-1,31), labels)
        return cross_entropy

if __name__== '__main__':
    X = Variable(torch.randn(256,3,14,14).cuda())
    _net = net()
    _net.cuda()
    cross_entropy = _net.forward(X)
    learning_rate = 1e-4
    optimizer = torch.optim.Adam(_net.parameters(), lr=learning_rate)
    optimizer.zero_grad()
    cross_entropy.backward()