GRU NestedIOFunction error

In my model’s init function, I create a GRU layer.

self.gru = nn.GRU(self.global_dim, self.global_dim, 1)
	    for param in self.gru.parameters():
        	if param.dim() == 2:

When I want to use this gru in another function, like this:

 state = torch.zeros(1, 1, 100)
    	output, state = self.gru(autograd.Variable(torch.zeros(1,1,100)).cuda(), state)

It just showed me the following error:

ValueError: NestedIOFunction doesn't know how to process an input object of type torch.FloatTensor

I couldn’t figure out why.

state has to be a Variable: state = Variable(torch.zeros(1, 1, 100))