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

在测试Internvl-76B的时候,报错RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cpu and cuda:0! #723

Open
starevelyn opened this issue Jan 15, 2025 · 5 comments
Assignees

Comments

@starevelyn
Copy link

starevelyn commented Jan 15, 2025

在测试Internvl-76B的时候,代码如下:
`from vlmeval.config import supported_VLM
model = supported_VLM'InternVL2-76B-sft'

ret = model.generate(['assets/apple.jpg', 'What is in this image?']) #前向单张图片
print(ret) # 这张图片上有一个带叶子的红苹果

ret = model.generate(['assets/apple.jpg', 'assets/apple.jpg', 'How many apples are there in the provided images? ']) # 前向多张图片
print(ret) # 提供的图片中有两个苹果`

报的错误是:
image
image

RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cpu and cuda:0! (when checking argument for argument mat2 in method wrapper_CUDA_bmm)

请问一下这个如何解决?

@starevelyn
Copy link
Author

image
代码改成这样就跑通了。。

@starevelyn
Copy link
Author

image
image
跑到20%多又报错。。

@PhoenixZ810
Copy link
Collaborator

你好,一般情况下我们默认推理Internvl-76B需要四张卡以防止out of memory。具体的切分方法在split_model函数中。

@PhoenixZ810 PhoenixZ810 self-assigned this Jan 16, 2025
@starevelyn
Copy link
Author

你好,一般情况下我们默认推理Internvl-76B需要四张卡以防止out of memory。具体的切分方法在split_model函数中。

我有8张卡在跑,显存应该是够的,但是就是会报错同时用了cpu和cuda,感觉是代码的问题。。按理来说应该只用cuda的,不知道cpu为啥用到

@PhoenixZ810
Copy link
Collaborator

可以print split_model()函数的结果device_mapvisible_devices看一下,是否能和本地的环境对齐

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