Thanks for your reply, my environments are as follow:
PyTorch:
In [2]: print torch.__version__
0.1.12_2

Installed via pip following the official instructions.
OS:
uname -a
Linux server01 4.4.0-72-generic #93~14.04.1-Ubuntu SMP Fri Mar 31 15:05:15 UTC 2017 x86_64 x86_64 x86_64 
GNU/Linux

CUDA:
nvcc --version
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2016 NVIDIA Corporation
Built on Sun_Sep__4_22:14:01_CDT_2016
Cuda compilation tools, release 8.0, V8.0.44

The error mentioned before occurs both on CPU and GPU mode, so it seems not to be a CUDA problem.