ucam-smt / sgnmt

Decoding platform for machine translation research
http://ucam-smt.github.io/sgnmt/html/
Apache License 2.0
55 stars 18 forks source link

Failed to run ' English-French WMT‘14 example' #10

Open Ga091an opened 3 years ago

Ga091an commented 3 years ago

Here's my log:

Tried CUDA_VISIBLE_DEVICES=0 python decode.py --config_file fairseq.ini and python decode.py --config_file fairseq.ini . Both got the same results.


021-01-22 09:52:11,907 INFO: Setting up fairseq library... [28/1021] | [en] dictionary: 43771 types | [fr] dictionary: 43807 types 2021-01-22 09:52:12,027 INFO: Loading fairseq model(s) from wmt14.en-fr.fconv-py/model.pt 2021-01-22 09:52:23,232 INFO: Initialized predictor fairseq (weight: 1.0) Starting interactive mode... PID: 109794 Display help with 'help' Quit with ctrl-d or 'quit' sgnmt> I am fine 2021-01-22 09:52:33,695 INFO: Start time: 1611280353.6951516 2021-01-22 09:52:33,695 INFO: Next sentence (ID: 1): I am fine 2021-01-22 09:52:33,695 DEBUG: BPE segmentation: 'I am fine' => 'I am fine' (53 681 3414) 2021-01-22 09:52:33,724 ERROR: An unexpected <class 'RuntimeError'> error has occurred at sentence id 1: Expected object of dev ice type cuda but got device type cpu for argument #3 'index' in call to _th_indexselect, Stack trace: Traceback (most recent call last): File "/root/anaconda3/envs/gq36/lib/python3.6/cmd.py", line 214, in onecmd func = getattr(self, 'do' + cmd) AttributeError: 'SGNMTPrompt' object has no attribute 'do_I'

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/data/gaoqian/sgnmt/cam/sgnmt/decode_utils.py", line 905, in do_decode hypos = [hypo for hypo in decoder.decode(src) File "/data/gaoqian/sgnmt/cam/sgnmt/decoding/beam.py", line 202, in decode for next_hypo in self._expand_hypo(hypo): File "/data/gaoqian/sgnmt/cam/sgnmt/decoding/beam.py", line 121, in _expand_hypo posterior, score_breakdown = self.apply_predictors(self.sub_beam_size) File "/data/gaoqian/sgnmt/cam/sgnmt/decoding/core.py", line 544, in apply_predictors posterior, score_breakdown = self.apply_predictors(self.sub_beam_size) [0/1021] File "/data/gaoqian/sgnmt/cam/sgnmt/decoding/core.py", line 544, in apply_predictors bounded_posteriors = [p.predictnext() for (p, ) in bounded_predictors] File "/data/gaoqian/sgnmt/cam/sgnmt/decoding/core.py", line 544, in bounded_posteriors = [p.predictnext() for (p, ) in bounded_predictors] File "/data/gaoqian/sgnmt/cam/sgnmt/predictors/pytorch_fairseq.py", line 112, in predict_next torch.LongTensor([self.consumed]), self.encoder_outs File "/root/anaconda3/envs/gq36/lib/python3.6/site-packages/torch/autograd/grad_mode.py", line 49, in decorate_no_grad return func(*args, kwargs) File "/root/anaconda3/envs/gq36/lib/python3.6/site-packages/fairseq/sequence_generator.py", line 578, in forward_decoder temperature=temperature, File "/root/anaconda3/envs/gq36/lib/python3.6/site-packages/fairseq/sequence_generator.py", line 608, in _decode_one decoder_out = list(model.decoder(tokens, encoder_out, incremental_state=self.incremental_states[model])) File "/root/anaconda3/envs/gq36/lib/python3.6/site-packages/torch/nn/modules/module.py", line 532, in call result = self.forward(*input, *kwargs) File "/root/anaconda3/envs/gq36/lib/python3.6/site-packages/fairseq/models/fconv.py", line 426, in forward pos_embed = self.embed_positions(prev_output_tokens, incremental_state) File "/root/anaconda3/envs/gq36/lib/python3.6/site-packages/torch/nn/modules/module.py", line 532, in call result = self.forward(input, kwargs) File "/root/anaconda3/envs/gq36/lib/python3.6/site-packages/fairseq/modules/learned_positional_embedding.py", line 44, in for ward return super().forward(positions) File "/root/anaconda3/envs/gq36/lib/python3.6/site-packages/torch/nn/modules/sparse.py", line 114, in forward self.norm_type, self.scale_grad_by_freq, self.sparse) File "/root/anaconda3/envs/gq36/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

Ga091an commented 3 years ago
lidongxing commented 2 years ago

I have two GPU devices and try those: CUDA_VISIBLE_DEVICES="0,1" python sgnmt/decode.py --config_file fairseq.ini or CUDA_VISIBLE_DEVICES="0" python sgnmt/decode.py --config_file fairseq.ini The errors: RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cuda:0 and cpu! (when checking argument for argument index in method wrapper__index_select)