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

runtime error #17

Open
nonva opened this issue Jan 17, 2020 · 2 comments
Open

runtime error #17

nonva opened this issue Jan 17, 2020 · 2 comments

Comments

@nonva
Copy link

nonva commented Jan 17, 2020

Traceback (most recent call last): ] 0% loss = ...
File "train.py", line 183, in
main()
File "train.py", line 111, in main
train_model(model, opt)
File "train.py", line 34, in train_model
src_mask, trg_mask = create_masks(src, trg_input, opt)
File "/dockerdata/bert_seq2seq/Transformer-master/Batch.py", line 25, in create_masks
trg_mask = trg_mask & np_mask
RuntimeError: Expected object of device type cuda but got device type cpu for argument #1 'self' in call to _th_and

how to solve the problem

@MehwishFatimah
Copy link

np_mask = np_mask.cuda()
trg_mask = trg_mask.cuda()
trg_mask = trg_mask & np_mask

It will resolve the issue, hopefully.

@MehwishFatimah
Copy link

Traceback (most recent call last): ] 0% loss = ...
File "train.py", line 183, in
main()
File "train.py", line 111, in main
train_model(model, opt)
File "train.py", line 34, in train_model
src_mask, trg_mask = create_masks(src, trg_input, opt)
File "/dockerdata/bert_seq2seq/Transformer-master/Batch.py", line 25, in create_masks
trg_mask = trg_mask & np_mask
RuntimeError: Expected object of device type cuda but got device type cpu for argument #1 'self' in call to _th_and

how to solve the problem

Check your device, I would suggest to pass it as a parameter in all function calls to avoid device conflict.

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

No branches or pull requests

2 participants