-
Notifications
You must be signed in to change notification settings - Fork 1.1k
fix: DocVLMPredictor
device use error
#4348
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
base: develop
Are you sure you want to change the base?
fix: DocVLMPredictor
device use error
#4348
Conversation
Thanks for your contribution! |
DocVLMPredictor
device use error
@luotao1 能帮忙看看 cla 为啥过不了嘛,还有应该找谁 review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
哈喽,感谢PR。
- 先来说一下为什么会有两套的device设置:因为目前doc_vlm之下的vlm模型只支持动态图的推理,和PaddleX下其他使用静态图的模型不太一样,所以在设计最初避开了对pp_option的使用,做了隔离,直接通过传入的device来在指定设备上推理。
- 再来说一下为什么pp structure会有相关问题:因为对于
PPStructureV3(device="cpu")
这里传入的device参数,PaddleOCR内部会直接封装出pp_option,并不会再单独传入device参数给doc_vlm的predictor,所以这导致在structure产线下,doc_vlm模块收到的device参数永远是None,从而导致在有gpu的情况下,会加载部分模型参数到0号线卡上。 - 这个PR中,先对device检查,之后再检查pp_option,确实是个解决这个问题的很好的方法,但是依然存在一些问题:
self.pp_option.device_type != "cpu"
如果设置device为cpu,那self.device依然是None,依然会加载模型到gpu:0上。
方便的话,辛苦更正上述问题重新PR。
done,我这没有权限能查看 ci 日志,能帮忙看看 ci 挂了是啥原因嘛 |
哈喽,感谢PR。 依然存在一些小问题哈,在你的逻辑里: self.device = constr_device(
self.pp_option.device_type,
(
str(self.pp_option.device_id)
if self.pp_option.device_type != "cpu"
else None
),
) 如果设置 方便的话,辛苦更正上述问题重新PR。 感谢您的共享精神,besides,代码的修改所涉及的所有变量,辛苦考虑到每一种可能的情况。 |
…edictor_gpu_memory_usage
…edictor_gpu_memory_usage
Done |
fix
DocVLMPredictor
显存分配异常情况复现代码
表现形式
当使用
PPStructureV3(device="cpu")
, 同时有 gpu 时,DocVLMPredictor
下的几个模型会被加载到gpu:0
上,并占用大约 2034MiB 显存修复方案
kwargs
传入,当 device 为 None 时加载pp_option
中的 device。(paddlex 框架内居然有两种 device 加载选项挺奇怪的)TODO
paddlex/inference/models/common/vlm/flash_attn_utils.py
下的is_flash_attn_available
函数也有类似问题,需要换一种形式确认是否支持flash_attention