Transformer
Transformer copied to clipboard
runtime error
Traceback (most recent call last): ] 0% loss = ...
File "train.py", line 183, in
how to solve the problem
np_mask = np_mask.cuda() trg_mask = trg_mask.cuda() trg_mask = trg_mask & np_mask
It will resolve the issue, hopefully.
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.