Skip to content
This repository has been archived by the owner on Mar 19, 2021. It is now read-only.

Error using CUDA #10

Open
rsteca opened this issue May 15, 2019 · 4 comments
Open

Error using CUDA #10

rsteca opened this issue May 15, 2019 · 4 comments

Comments

@rsteca
Copy link

rsteca commented May 15, 2019

I get this error when trying to use the code with GPU (it works fine with CPU):

2019-05-14 19:51:48,675 - VOC_TOPICS - INFO - Shape of data: (40560, 82).
Missing in data: 0.
2019-05-14 19:51:48,785 - VOC_TOPICS - INFO - Training size: 28392.
2019-05-14 19:51:51,329 - VOC_TOPICS - INFO - Iterations per epoch: 221.812 ~ 222.
Traceback (most recent call last):
  File "main.py", line 196, in <module>
    iter_loss, epoch_loss = train(model, data, config, n_epochs=10, save_plots=save_plots)
  File "main.py", line 84, in train
    loss = train_iteration(net, t_cfg.loss_func, feats, y_history, y_target)
  File "main.py", line 143, in train_iteration
    input_weighted, input_encoded = t_net.encoder(numpy_to_tvar(X))
  File "/usr/local/lib/python3.6/dist-packages/torch/nn/modules/module.py", line 493, in __call__
    result = self.forward(*input, **kwargs)
  File "/content/da-rnn/da-rnn/modules.py", line 43, in forward
    input_data.permute(0, 2, 1)), dim=2)  # batch_size * input_size * (2*hidden_size + T - 1)
RuntimeError: Expected object of backend CPU but got backend CUDA for sequence element 2 in sequence argument at position #1 'tensors'
@ywatanabe1989
Copy link

Me too.

@shwangdev
Copy link

Me tooo

@barryflower
Copy link

Yes, the same problem. Has this been tested with cuda?

@barryflower
Copy link

barryflower commented Jul 10, 2019

Further to this problem there is an easy fix. Just add/change the following 3 lines in modules.py. Starting from the bottom so that the line numbers I show don't change.

Change line 59 to:
return input_weighted, input_encoded.to(device) # Fixed CUDA bug #

Change line 11 to:
return Variable(torch.zeros(1, x.size(0), hidden_size).to(device)) # Fixed CUDA bug #

Add after line 4:
from constants import device # Fixed CUDA bug BF 20190710 #

Thats it!

RainerHeintzmann added a commit to RainerHeintzmann/da-rnn that referenced this issue Mar 21, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants