Fixing the error facing in google colab

#6
by Roy-Pentagon - opened

When using (the device) in an argument getting this error in google colab
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_CUDA__index_select)

when used .to('cpu'), it runs smoothly and gets the desired result.
Fix this issue

This comment has been hidden

Change this code to and it will work setting the same device when calling model for inference

input_ids = tokenizer(
f'paraphrase: {question}',
return_tensors="pt", padding="longest",
max_length=max_length,
truncation=True,
).input_ids

TO

input_ids = tokenizer(
f'paraphrase: {question}',
return_tensors="pt", padding="longest",
max_length=max_length,
truncation=True,
).input_ids.to(device)

NOTE: to(device)

Ready to merge
This branch is ready to get merged automatically.

Sign up or log in to comment