Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error for cuda and cpu #185

Open
lucasjinreal opened this issue Dec 19, 2018 · 8 comments
Open

Error for cuda and cpu #185

lucasjinreal opened this issue Dec 19, 2018 · 8 comments

Comments

@lucasjinreal
Copy link

/pytorch-seq2seq/seq2seq/models/EncoderRNN.py", line 68, in forward
    embedded = self.embedding(input_var)
  File "/usr/local/lib/python3.6/dist-packages/torch/nn/modules/module.py", line 479, in __call__
    result = self.forward(*input, **kwargs)
  File "/usr/local/lib/python3.6/dist-packages/torch/nn/modules/sparse.py", line 113, in forward
    self.norm_type, self.scale_grad_by_freq, self.sparse)
  File "/usr/local/lib/python3.6/dist-packages/torch/nn/functional.py", line 1283, in embedding
    return torch.embedding(weight, input, padding_idx, scale_grad_by_freq, sparse)
RuntimeError: Expected object of backend CUDA but got backend CPU for argument #3 'index'

@pskrunner14
Copy link

@jinfagang could you try running your code with develop branch?

@xiaodaoyoumin
Copy link

bug bug bug !!!!!!!!!!!!!!!!!!!!!!!!!!!! waste my time!!!!!!!!!!!

@lucasjinreal
Copy link
Author

@Hujun-Cui I think this repo is not active maintained now.

@pskrunner14
Copy link

@jinfagang this has been a recurring issue, however the fix has already been made on the develop branch. Will update on master soon. Please see #180 for a simple workaround.

@v587su
Copy link

v587su commented May 21, 2019

The wrong code is at line 75 of supervised_trainer.py and line 38 of evaluator.py.
I change them to device = torch.device('cuda:0') if torch.cuda.is_available() else -1 and CUDA is available now.

@rain1024
Copy link

rain1024 commented Jul 11, 2019

I think this should be merged in master now.

@Hexagram-King
Copy link

The wrong code is at line 75 of supervised_trainer.py and line 38 of evaluator.py.
I change them to device = torch.device('cuda:0') if torch.cuda.is_available() else -1 and CUDA is available now.

Except the two files, is there any other file need to fix? After fix the two files, the code still be incorrect...

@isekulic
Copy link

The wrong code is at line 75 of supervised_trainer.py and line 38 of evaluator.py.
I change them to device = torch.device('cuda:0') if torch.cuda.is_available() else -1 and CUDA is available now.

Except the two files, is there any other file need to fix? After fix the two files, the code still be incorrect...

No, but you need to re-install the package after you do these corrections. Running python setup.py install again helped in my case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants