Can anyone help test a snippet

I met some error on both of my machines; I don’t know if someone else can reproduce it.

import torch
x = torch.cuda.FloatTensor(1, 1, 16384, 16384)
x = torch.autograd.Variable(x, requires_grad=True)
y = x.expand(2, x.size(1), x.size(2), x.size(3))
grid = torch.rand(2, 1, 1, 2)
import torch.nn.functional as F
z = F.grid_sample(y, torch.autograd.Variable(grid.cuda()))

I got error

Traceback (most recent call last):
File “”, line 1, in
File “/opt/conda/lib/python2.7/site-packages/torch/autograd/”, line 156, in backward
torch.autograd.backward(self, gradient, retain_graph, create_graph, retain_variables)
File “/opt/conda/lib/python2.7/site-packages/torch/autograd/”, line 98, in backward
variables, grad_variables, retain_graph)
File “/opt/conda/lib/python2.7/site-packages/torch/autograd/”, line 91, in apply
return self._forward_cls.backward(self, *args)
File “/opt/conda/lib/python2.7/site-packages/torch/autograd/”, line 194, in wrapper
outputs = fn(ctx, *tensor_args)
File “/opt/conda/lib/python2.7/site-packages/torch/nn/_functions/”, line 48, in backward

It works fine when running under cpu mode.
It works also fine when replacing last line with z.backward(

torch version is ‘0.2.0+0cd149f’

Can someone try? At least tell me if it happens on your machine or not.

1 Like


I get the same. What do you need in terms of details?

Best regards


This seems like a bug right.
Because it works for z.backward(

1 Like

Same problem for me, find this thread, when googled similar problem with grid_sample backwards