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

推理中将多张图像cat在一起作为输入,出现CUDA out of memory #183

Open
aabbc-cell opened this issue May 20, 2024 · 1 comment

Comments

@aabbc-cell
Copy link

推理中,我使用1-2张图像cat在一起作为输入时,使用8张v100-32G(device_map="auto")能正常进行对话,但使用3张及以上图像(例如10张图像)cat在一起作为输入时,报错:
t)orch.cuda.OutOfMemoryError: CUDA out of memory. Tried to allocate 9.14 GiB. GPU 0 has a total capacity of 31.75 GiB of which 8.85 GiB is free. Process 18099 has 22.89 GiB memory in use. Of the allocated memory 22.12 GiB is allocated by PyTorch, and 414.56 MiB is reserved by PyTorch but unallocated. If reserved but unallocated memory is large try setting PYTORCH_CUDA_ALLOC_CONF=expandable_segments:True to avoid fragmentation. See documentation for Memory Management (https://pytorch.org/docs/stable/notes/cuda.html#environment-variables)
这是因为device_map="auto"的分配不均吗?但我自己重新设置device_map时仍报错CUDA out of memory

@czczup
Copy link
Member

czczup commented May 30, 2024

拼起来之后的图片大概有多少个patch? 如果图片数量很多的话,可以试试load_image函数里max_num给小点,原本给的例子里是6,可以试试4。

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