OpenBMB / MiniCPM-V

MiniCPM-V 2.6: A GPT-4V Level MLLM for Single Image, Multi Image and Video on Your Phone
Apache License 2.0
12.44k stars 871 forks source link

[BUG] <title>官方的web_demo_2.6.py示例在使用过程中显存没有正常释放。 #632

Open 376x opened 2 weeks ago

376x commented 2 weeks ago

是否已有关于该错误的issue或讨论? | Is there an existing issue / discussion for this?

该问题是否在FAQ中有解答? | Is there an existing answer for this in FAQ?

当前行为 | Current Behavior

环境:python3.10 包:Package Version


accelerate 0.30.1 addict 2.4.0 aiofiles 23.2.1 annotated-types 0.7.0 anyio 4.6.0 attrs 24.2.0 bitsandbytes 0.44.1 certifi 2024.8.30 charset-normalizer 3.4.0 click 8.1.7 colorama 0.4.6 contourpy 1.3.0 cycler 0.12.1 decord 0.6.0 editdistance 0.6.2 einops 0.7.0 et-xmlfile 1.1.0 exceptiongroup 1.2.2 fairscale 0.4.0 fastapi 0.112.2 ffmpy 0.4.0 filelock 3.16.1 fonttools 4.54.1 fsspec 2024.9.0 gradio 4.41.0 gradio_client 1.3.0 h11 0.14.0 httpcore 1.0.6 httpx 0.27.2 huggingface-hub 0.25.2 idna 3.10 importlib_resources 6.4.5 Jinja2 3.1.4 joblib 1.4.2 jsonlines 4.0.0 kiwisolver 1.4.7 lxml 5.3.0 markdown-it-py 3.0.0 markdown2 2.4.10 MarkupSafe 2.1.5 matplotlib 3.7.4 mdurl 0.1.2 modelscope_studio 0.4.0.9 more-itertools 10.1.0 mpmath 1.3.0 networkx 3.4 nltk 3.8.1 numpy 1.24.4 opencv-python-headless 4.5.5.64 openpyxl 3.1.2 orjson 3.10.7 packaging 23.2 pandas 2.2.3 Pillow 10.1.0 pip 24.2 portalocker 2.10.1 protobuf 4.25.0 psutil 6.0.0 pydantic 2.9.2 pydantic_core 2.23.4 pydub 0.25.1 Pygments 2.18.0 pyparsing 3.1.4 python-dateutil 2.9.0.post0 python-multipart 0.0.12 pytz 2024.2 pywin32 307 PyYAML 6.0.2 regex 2024.9.11 requests 2.32.3 rich 13.9.2 ruff 0.6.9 sacrebleu 2.3.2 safetensors 0.4.5 seaborn 0.13.0 semantic-version 2.10.0 sentencepiece 0.1.99 setuptools 75.1.0 shellingham 1.5.4 shortuuid 1.0.11 six 1.16.0 sniffio 1.3.1 socksio 1.0.0 starlette 0.38.6 sympy 1.13.3 tabulate 0.9.0 timm 0.9.10 tokenizers 0.19.1 tomlkit 0.12.0 torch 2.4.0+cu118 torchaudio 2.4.0+cu118 torchvision 0.19.0+cu118 tqdm 4.66.1 transformers 4.40.0 typer 0.12.5 typing_extensions 4.8.0 tzdata 2024.2 urllib3 2.2.3 uvicorn 0.24.0.post1 websockets 12.0 wheel 0.44.0

在上传视频文件,官方示例encode_video方法对视频进行切帧后,完成回复没有及时清理图片帧占用的显存。

期望行为 | Expected Behavior

在respond方法的末尾加上torch.cuda.empty_cache()可以暂时解决这个问题。 溢出的显存占用会有一部分内容在内存存储继续运行,影响后续回答效率。

复现方法 | Steps To Reproduce

No response

运行环境 | Environment

- OS:
- Python:
- Transformers:
- PyTorch:
- CUDA (`python -c 'import torch; print(torch.version.cuda)'`):

备注 | Anything else?

No response

LDLINGLINGLING commented 2 weeks ago

您好,请问显存溢出仅出现在encode_video这个方法中么

376x commented 2 weeks ago

是的,在我使用过程中显存溢出仅出现在encode_video这个方法