Transformer icon indicating copy to clipboard operation
Transformer copied to clipboard

runtime error

Open nonva opened this issue 5 years ago • 2 comments

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

nonva avatar Jan 17 '20 13:01 nonva

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

It will resolve the issue, hopefully.

MehwishFatimah avatar Mar 19 '20 16:03 MehwishFatimah

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.

MehwishFatimah avatar Jun 26 '20 08:06 MehwishFatimah