This code works on my install from master branch.
How old is the version you compiled with? You can print(torch.__version__) to check that you are actually using the master branch (should be 0.4) and not another version installed somewhere else.