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

Help: examples/mt/mt.py #4

Open
remotejob opened this issue Aug 6, 2019 · 1 comment
Open

Help: examples/mt/mt.py #4

remotejob opened this issue Aug 6, 2019 · 1 comment

Comments

@remotejob
Copy link

I try reproduce examples/mt/mt.py but I have CPU/CUDA error:

File "/opt/conda/lib/python3.6/site-packages/allennlp/models/encoder_decoders/simple_seq2seq.py", line 212, in forward state = self._encode(source_tokens) File "/opt/conda/lib/python3.6/site-packages/allennlp/models/encoder_decoders/simple_seq2seq.py", line 268, in _encode embedded_input = self._source_embedder(source_tokens) File "/opt/conda/lib/python3.6/site-packages/torch/nn/modules/module.py", line 493, in __call__ result = self.forward(*input, **kwargs) File "/opt/conda/lib/python3.6/site-packages/allennlp/modules/text_field_embedders/basic_text_field_embedder.py", line 123, in forward token_vectors = embedder(*tensors) File "/opt/conda/lib/python3.6/site-packages/torch/nn/modules/module.py", line 493, in __call__ result = self.forward(*input, **kwargs) File "/opt/conda/lib/python3.6/site-packages/allennlp/modules/token_embedders/embedding.py", line 143, in forward sparse=self.sparse) File "/opt/conda/lib/python3.6/site-packages/torch/nn/functional.py", line 1506, in embedding return torch.embedding(weight, input, padding_idx, scale_grad_by_freq, sparse) RuntimeError: Expected object of backend CPU but got backend CUDA for argument #3 'index'

I try play in kaggle enveroment

@remotejob
Copy link
Author

Probably simple:

device = torch.device("cuda" if torch.cuda.is_available() else "cpu")


model = model.to(device)

Must help !?

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

1 participant