-
Notifications
You must be signed in to change notification settings - Fork 25.2k
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
BLIP2 inference error: Expected all tensors to be on the same device, but found at least two devices, cuda:7 and cuda:2 #26806
Comments
pinging @SunMarc and @younesbelkada as well! |
Environment Config transformers== 4.34.0
accelerate== 0.23.0
torch== 2.0.1+cu117 Beside, I found a warning when I run with The `language_model` is not in the `hf_device_map` dictionary and you are running your script in a multi-GPU environment.
this may lead to unexpected behavior when using `accelerate`. Please pass a `device_map` that contains `language_model` to remove this warning. Does Anorther Question (Although it's a CUDA bug.) os.environ["CUDA_VISIBLE_DEVICES"] = "0,1"
import torch
model = Blip2ForConditionalGeneration.from_pretrained("Salesforce/blip2-opt-2.7b").to("cuda") Error:torch.cuda.DeferredCudaCallError: CUDA call failed lazily at initialization with error: device >= 0 && device < num_gpus |
@SunMarc How to lock the usage of |
I think it is a problem with torch and cuda. In the past, we had a similar case. Can you reinstall and try again ? Also, the following code snippet works on my side:
As for the warning, this is something we need to fix. It shouldn't show the warning. |
@SunMarc yes, I can use tokenizer = T5Tokenizer.from_pretrained("google/flan-t5-xxl")
model = T5ForConditionalGeneration.from_pretrained("google/flan-t5-xxl", device_map="auto") So I wonder is it a problem with |
This issue has been automatically marked as stale because it has not had recent activity. If you think this still needs to be addressed please comment on this thread. Please note that issues that do not follow the contributing guidelines are likely to be ignored. |
System Info
Describe the bug
RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cuda:7 and cuda:2.
Screenshots
System info (please complete the following information):
How can I fix this bug?
Who can help?
@pacman100
Information
Tasks
examples
folder (such as GLUE/SQuAD, ...)Reproduction
To Reproduce
I am trying to enable multi-gpus inference on the BLIP2 model.
I tried the following code snippet:
Expected behavior
The BLIP2 model loads and runs successfully on multi-GPUs.
The text was updated successfully, but these errors were encountered: