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

Got RuntimeError when run on Google Colab #8

Open
kietbg0079 opened this issue Jan 5, 2023 · 1 comment
Open

Got RuntimeError when run on Google Colab #8

kietbg0079 opened this issue Jan 5, 2023 · 1 comment

Comments

@kietbg0079
Copy link

kietbg0079 commented Jan 5, 2023

I ran the Readme.md samples on Google Colab with GPU and got this Error "RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cpu and cuda:0! (when checking argument for argument index in method wrapper__index_select)".

Error code:
outputs = model.generate(tokenizer(inputs, return_tensors="pt", padding=True).input_ids.to('cuda'), max_length=512)

@heraclex12
Copy link
Collaborator

Hi @kietbg0079

Sorry for not getting back to you sooner, to overcome this error, you should assign the model to GPU as well.

For example: model.cuda()

We will update the example code more accurately.

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

2 participants