ShaHon commited on
Commit
b711998
1 Parent(s): 5e8c6dc

Add to(device) to "input_ids"

Browse files

If the model is taken to the GPU but not the tokenized "input ids" then the following runtime error will be raised:
`RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cuda:0 and cpu`
Therefore, .input_ids should be modified to .input_ids.to(device).

Ref:
https://stackoverflow.com/a/75831568/10216028

Files changed (1) hide show
  1. README.md +1 -1
README.md CHANGED
@@ -65,7 +65,7 @@ def paraphrase(
65
  return_tensors="pt", padding="longest",
66
  max_length=max_length,
67
  truncation=True,
68
- ).input_ids
69
 
70
  outputs = model.generate(
71
  input_ids, temperature=temperature, repetition_penalty=repetition_penalty,
 
65
  return_tensors="pt", padding="longest",
66
  max_length=max_length,
67
  truncation=True,
68
+ ).input_ids.to(device)
69
 
70
  outputs = model.generate(
71
  input_ids, temperature=temperature, repetition_penalty=repetition_penalty,