Traceback (most recent call last):


 "/content/OpenNMT-py/onmt/trainer.py", line 347, in _gradient_accumulation

trunc_size=trunc_size)


 "/content/OpenNMT-py/onmt/utils/loss.py", line 158, in __call__

loss, stats = self._compute_loss(batch, **shard)


 "/content/OpenNMT-py/onmt/utils/loss.py", line 233, in _compute_loss

scores = self.generator(bottled_output)


 "/usr/local/lib/python3.6/dist-packages/torch/nn/modules/module.py", line 489, in __call__

result = self.forward(*input, **kwargs)


 "/usr/local/lib/python3.6/dist-packages/torch/nn/modules/container.py", line 92, in forward

input = module(input)


 "/usr/local/lib/python3.6/dist-packages/torch/nn/modules/module.py", line 489, in __call__

result = self.forward(*input, **kwargs)


 "/usr/local/lib/python3.6/dist-packages/torch/nn/modules/linear.py", line 67, in forward

return F.linear(input, self.weight, self.bias)


 "/usr/local/lib/python3.6/dist-packages/torch/nn/functional.py", line 1352, in linear

ret = torch.addmm(torch.jit._unwrap_optional(bias), input, weight.t())
RuntimeError: Expected object of backend CPU but got backend CUDA for argument #4 'mat1'

Traceback (most recent call last):


 "run_seq_labeling.py", line 811, in <module>

main()


 "run_seq_labeling.py", line 704, in main

args, train_dataset, model, tokenizer, labels, pad_token_label_id


 "run_seq_labeling.py", line 219, in train

outputs = model(**inputs)


 "/home/ubuntu/anaconda3/envs/layoutlm/lib/python3.6/site-packages/torch/nn/modules/module.py", line 532, in __call__

result = self.forward(*input, **kwargs)


 "/home/ubuntu/anaconda3/envs/layoutlm/lib/python3.6/site-packages/layoutlm/modeling/layoutlm.py", line 217, in forward

head_mask=head_mask,


 "/home/ubuntu/anaconda3/envs/layoutlm/lib/python3.6/site-packages/torch/nn/modules/module.py", line 532, in __call__

result = self.forward(*input, **kwargs)


 "/home/ubuntu/anaconda3/envs/layoutlm/lib/python3.6/site-packages/layoutlm/modeling/layoutlm.py", line 171, in forward

input_ids, bbox, position_ids=position_ids, token_type_ids=token_type_ids


 "/home/ubuntu/anaconda3/envs/layoutlm/lib/python3.6/site-packages/torch/nn/modules/module.py", line 532, in __call__

result = self.forward(*input, **kwargs)


 "/home/ubuntu/anaconda3/envs/layoutlm/lib/python3.6/site-packages/layoutlm/modeling/layoutlm.py", line 84, in forward

token_type_embeddings = self.token_type_embeddings(token_type_ids)


 "/home/ubuntu/anaconda3/envs/layoutlm/lib/python3.6/site-packages/torch/nn/modules/module.py", line 532, in __call__

result = self.forward(*input, **kwargs)


 "/home/ubuntu/anaconda3/envs/layoutlm/lib/python3.6/site-packages/torch/nn/modules/sparse.py", line 114, in forward

self.norm_type, self.scale_grad_by_freq, self.sparse)


 "/home/ubuntu/anaconda3/envs/layoutlm/lib/python3.6/site-packages/torch/nn/functional.py", line 1484, in embedding

return torch.embedding(weight, input, padding_idx, scale_grad_by_freq, sparse)
RuntimeError: Expected object of device type cuda but got device type cpu for argument #3 'index' in call to _th_index_select
