Solved by Usama_Hasan in post #2 
              
              
                Hy, the error is generated at this line. 
model.hidden = (torch.zeros(1,1,model.hidden_size).cuda(),
                       torch.zeros(1,1,model.hidden_size).cuda())

Right then you should modify your LSTM class like this. 
class LSTM(nn.Module):
   def init(self, input_size=1, hidden_size=100):
  …