I get the same trouble, do you find some solutions?
  File "/home/liuchenfeng/code/py-SMDNet/pretrain/train_smdnet.py", line 180, in <module>
    train_smdnet()
  File "/home/liuchenfeng/code/py-SMDNet/pretrain/train_smdnet.py", line 149, in train_smdnet
    loss.backward()
  File "/usr/local/lib/python2.7/dist-packages/torch/tensor.py", line 93, in backward
    torch.autograd.backward(self, gradient, retain_graph, create_graph)
  File "/usr/local/lib/python2.7/dist-packages/torch/autograd/__init__.py", line 89, in backward
    allow_unreachable=True)  # allow_unreachable flag
RuntimeError: leaf variable has been moved into the graph interior