I have checked other posts on the Cuda runtime error 59 and most of them are related to accessing out-of-bound indices but my error seems to be occurring during backprop and not in the forward prop (if it was an out-of-bound index, it would have happened in forward prop). The detailed error message is below:
THCudaCheck FAIL file=/data/users/soumith/builder/wheel/pytorch-src/torch/lib/THCUNN/generic/Threshold.cu line=66 error=59 : device-side assert triggered
Traceback (most recent call last):
  File "srnn/train.py", line 191, in <module>
    main()
  File "srnn/train.py", line 80, in main
    train(args)
  File "srnn/train.py", line 159, in train
    loss.backward()
  File "/home/anirudh/.virtualenvs/gp/local/lib/python2.7/site-packages/torch/autograd/variable.py", line 146, in backward
    self._execution_engine.run_backward((self,), (gradient,), retain_variables)
  File "/home/anirudh/.virtualenvs/gp/local/lib/python2.7/site-packages/torch/nn/_functions/thnn/auto.py", line 174, in backward
    update_grad_input_fn(self._backend.library_state, input, grad_output, grad_input, *gi_args)
RuntimeError: cuda runtime error (59) : device-side assert triggered at /data/users/soumith/builder/wheel/pytorch-src/torch/lib/THCUNN/generic/Threshold.cu:66