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

Unable to load on multiple GPUs using HuggingFace Transformers #771

Open
mohammad-yousuf opened this issue May 12, 2024 · 1 comment
Open

Comments

@mohammad-yousuf
Copy link

When I try to load on multiple GPUS, I get the following error:

tokenizer = AutoTokenizer.from_pretrained('BAAI/bge-reranker-base')
model = AutoModelForSequenceClassification.from_pretrained('BAAI/bge-reranker-base', device_map='auto')

error: 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)

@mohammad-yousuf mohammad-yousuf changed the title Unable to load on multiple GPUS using HuggingFace Transformers Unable to load on multiple GPUs using HuggingFace Transformers May 12, 2024
@staoxiao
Copy link
Collaborator

Hi, @mohammad-yousuf , you need to move the data to the GPU device before passing it to the model:

device = torch.device('cuda')
encoded_input = encoded_input.to(device)

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