Need help on running code!

(problem is fixed now!!)
(problem is fixed now!!, I just need to change my label from 1-5 to 0-4, and then use n_classes = 5)
Hi, there. I am working on reproducing a paper ‘Very Deep Convolutional Networks for Text Classification’ as a final project. I have been runing with no problem on my own GPU.

Full Code

But, when I run it on a server, the following error pops up.

Traceback (most recent call last):
  File "", line 313, in <module>
  File "/mnt/bwpy/single/usr/lib/python3.5/site-packages/torch/", line 93, in backward
    torch.autograd.backward(self, gradient, retain_graph, create_graph)
  File "/mnt/bwpy/single/usr/lib/python3.5/site-packages/torch/autograd/", line 90, in backward
    allow_unreachable=True)  # allow_unreachable flag
RuntimeError: cublas runtime error : an internal operation failed at /dev/shm/cmaclean/python-single/portage/sci-libs/caffe2-0.4.1/work/pytorch-0.4.1/aten/src/THC/

I am new to deep learning, my knowledge is limited. It could be my code is wrong somewhere but I can not tell right now. I have to get it working on the server to run hundreds of hours. Any help is appreciated!

Is this the complete stack trace ?

Post the stack trace you get after running your code in the following manner.

/dev/shm/cmaclean/python-single/portage/sci-libs/caffe2-0.4.1/work/pytorch-0.4.1/aten/src/THCUNN/ void cunn_ClassNLLCriterion_updateOutput_kernel(Dtype *, Dtype *, Dtype *, long *, Dtype *, int, int, int, int, long) [with Dtype = float, Acctype = float]: block: [0,0,0], thread: [3,0,0] Assertion `t >= 0 && t < n_classes` failed.
THCudaCheck FAIL file=/dev/shm/cmaclean/python-single/portage/sci-libs/caffe2-0.4.1/work/pytorch-0.4.1/aten/src/THCUNN/generic/ line=111 error=59 : device-side assert triggered
Traceback (most recent call last):
  File "", line 308, in <module>
    loss = criterion(outputs, labels)
  File "/mnt/bwpy/single/usr/lib/python3.5/site-packages/torch/nn/modules/", line 477, in __call__
    result = self.forward(*input, **kwargs)
  File "/mnt/bwpy/single/usr/lib/python3.5/site-packages/torch/nn/modules/", line 862, in forward
    ignore_index=self.ignore_index, reduction=self.reduction)
  File "/mnt/bwpy/single/usr/lib/python3.5/site-packages/torch/nn/", line 1550, in cross_entropy
    return nll_loss(log_softmax(input, 1), target, weight, None, ignore_index, None, reduction)
  File "/mnt/bwpy/single/usr/lib/python3.5/site-packages/torch/nn/", line 1407, in nll_loss
    return torch._C._nn.nll_loss(input, target, weight, _Reduction.get_enum(reduction), ignore_index)
RuntimeError: cuda runtime error (59) : device-side assert triggered at /dev/shm/cmaclean/python-single/portage/sci-libs/caffe2-0.4.1/work/pytorch-0.4.1/aten/src/THCUNN/generic/

Assertion `t >= 0 && t < n_classes` failed

It looks like my class labels are wrong. My input have labels from 1-5, and I used nclasses = 5 in the last linear layer.

Change labels from 1-5 to 0-4. I think this is causing the error. Because python, C++ uses 0 index.