The issue you linked is not applicable to your code snippet. It is about the specific norm operation of a zero tensor rather than any operation. Your code snippet works perfectly fine on vanilla 0.2 install.
To debug NaN grad, you can add backward hook at each step of your network, and print to see where they become NaN.