RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cuda:0 and cpu! in ch05/01_main-chapter-code/gpt_generate.py #435
Labels
bug
Something isn't working
Bug description
If code above runs in GPU device, error below would appear:
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)
Since the gpt model has been put to the GPU, the idx tensor from
text_to_token_ids(input_prompt, tokenizer)
has not been put to the GPU. So it should be modified astext_to_token_ids(input_prompt, tokenizer).to(device)
What operating system are you using?
Linux
Where do you run your code?
Other cloud environment (AWS, Azure, GCP)
Environment
The text was updated successfully, but these errors were encountered: