adapted from the example in http://pytorch.org/tutorials/advanced/numpy_extensions_tutorial.html: 9
import torch
print(torch.__version__)

class DummyFunction(torch.autograd.Function):
    def forward(self, x):
         self.save_for_backward(x)
         y = x.numpy() + 1
         return torch.from_numpy(y)

     def backward(self, y_grad):
         x = self.saved_tensors
         x_grad = y_grad.clone()
         x_grad = x_grad.numpy() + 1
         return torch.from_numpy(x_grad)
         # return torch.FloatTensor(x_grad)

input = torch.autograd.Variable(torch.rand(5), requires_grad=True)
output = DummyFunction()(input)
print(output)
output.backward(torch.rand(5))
print(input.grad)

This code outputs:
0.2.0_4
Variable containing:
 1.4786    
 1.8203
 1.4139
 1.2448
 1.8730
[torch.FloatTensor of size 5]

Segmentation fault (core dumped)

However, if I replace torch.from_numpy(…) with
ret = torch.zeros(x_grad.shape)
retnp = ret.numpy()
retnp += x_grad

and return ret, it works