dehoyosb/temporal_fusion_transformer_pytorch

Cuda error in Testing

fmobrj opened this issue · 0 comments

While iterating over the test dataloader, getting an error when calling output for a batch:

---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
<ipython-input-67-44c3ffdf007b> in <module>
      5         t = target
      6         batches += 1
----> 7         output = tft(batch)
      8         loss.append(q_risk.apply(output[Ellipsis, 1], target[Ellipsis, 0], 0.5))
      9     else:

~/anaconda3/envs/fastaiv2/lib/python3.6/site-packages/torch/nn/modules/module.py in __call__(self, *input, **kwargs)
    548             result = self._slow_forward(*input, **kwargs)
    549         else:
--> 550             result = self.forward(*input, **kwargs)
    551         for hook in self._forward_hooks.values():
    552             hook_result = hook(self, input, result)

<ipython-input-32-08fe9b5e3a22> in forward(self, all_inputs)
    310 
    311         unknown_inputs, known_combined_layer, obs_inputs, static_inputs \
--> 312             = self.get_tft_embeddings(regular_inputs, categorical_inputs)
    313 
    314         # Isolate known and observed historical inputs.

<ipython-input-32-08fe9b5e3a22> in get_tft_embeddings(self, regular_inputs, categorical_inputs)
    251 
    252             static_categorical_inputs = [self.categorical_var_embeddings[i](categorical_inputs[Ellipsis, i])[:,0,:] 
--> 253                                          for i in range(self.num_categorical_variables)
    254                                          if i + self.num_regular_variables in self._static_input_loc]
    255             #print('static_categorical_inputs')

<ipython-input-32-08fe9b5e3a22> in <listcomp>(.0)
    252             static_categorical_inputs = [self.categorical_var_embeddings[i](categorical_inputs[Ellipsis, i])[:,0,:] 
    253                                          for i in range(self.num_categorical_variables)
--> 254                                          if i + self.num_regular_variables in self._static_input_loc]
    255             #print('static_categorical_inputs')
    256             #print([print(emb.shape) for emb in static_categorical_inputs])

~/anaconda3/envs/fastaiv2/lib/python3.6/site-packages/torch/nn/modules/module.py in __call__(self, *input, **kwargs)
    548             result = self._slow_forward(*input, **kwargs)
    549         else:
--> 550             result = self.forward(*input, **kwargs)
    551         for hook in self._forward_hooks.values():
    552             hook_result = hook(self, input, result)

~/anaconda3/envs/fastaiv2/lib/python3.6/site-packages/torch/nn/modules/sparse.py in forward(self, input)
    112         return F.embedding(
    113             input, self.weight, self.padding_idx, self.max_norm,
--> 114             self.norm_type, self.scale_grad_by_freq, self.sparse)
    115 
    116     def extra_repr(self):

~/anaconda3/envs/fastaiv2/lib/python3.6/site-packages/torch/nn/functional.py in embedding(input, weight, padding_idx, max_norm, norm_type, scale_grad_by_freq, sparse)
   1722         # remove once script supports set_grad_enabled
   1723         _no_grad_embedding_renorm_(weight, input, max_norm, norm_type)
-> 1724     return torch.embedding(weight, input, padding_idx, scale_grad_by_freq, sparse)
   1725 
   1726 

RuntimeError: Expected object of device type cuda but got device type cpu for argument #3 'index' in call to _th_index_select

1
loss
[]