Skip to content

PaddleOCRVL 使用 python api 使用 GPU 执行推理,但是内存一直升高导致内存溢出 #16971

@StrawberryCake-Fish

Description

@StrawberryCake-Fish

🔎 Search before asking

  • I have searched the PaddleOCR Docs and found no similar bug report.
  • I have searched the PaddleOCR Issues and found no similar bug report.
  • I have searched the PaddleOCR Discussions and found no similar bug report.

🐛 Bug (问题描述)

我尝试通过手动安装 PaddlePaddle 和 PaddleOCR,希望进行一些的测试。

在程序执行的过程中我发现 RAM 一直在升高直至占满,最后进程由于内存溢出被杀死。

我不太清楚是否是因为我的显存不够的原因?还是说我需要一台更好的设备进行测试?

🏃‍♂️ Environment (运行环境)

OS Ubuntu24.04
RAM 32GB
GPU NVIDIA GeForce RTX 3060 Ti / 8GB
+-----------------------------------------------------------------------------------------+
| NVIDIA-SMI 580.95.05              Driver Version: 580.95.05      CUDA Version: 13.0     |
+-----------------------------------------+------------------------+----------------------+
| GPU  Name                 Persistence-M | Bus-Id          Disp.A | Volatile Uncorr. ECC |
| Fan  Temp   Perf          Pwr:Usage/Cap |           Memory-Usage | GPU-Util  Compute M. |
|                                         |                        |               MIG M. |
|=========================================+========================+======================|
|   0  NVIDIA GeForce RTX 3060 Ti     Off |   00000000:01:00.0 Off |                  N/A |
| 33%   39C    P0             31W /  200W |       0MiB /   8192MiB |      3%      Default |
|                                         |                        |                  N/A |
+-----------------------------------------+------------------------+----------------------+

+-----------------------------------------------------------------------------------------+
| Processes:                                                                              |
|  GPU   GI   CI              PID   Type   Process name                        GPU Memory |
|        ID   ID                                                               Usage      |
|=========================================================================================|
|  No running processes found                                                             |
+-----------------------------------------------------------------------------------------+
Package                  Version
------------------------ -----------------
aiohappyeyeballs         2.6.1
aiohttp                  3.12.13
aiosignal                1.3.2
aistudio-sdk             0.3.8
annotated-types          0.7.0
anyio                    4.9.0
attrs                    25.3.0
bce-python-sdk           0.9.49
beautifulsoup4           4.13.4
cachetools               6.1.0
certifi                  2025.6.15
chardet                  5.2.0
charset-normalizer       3.4.2
click                    8.2.1
colorlog                 6.9.0
conda-pack               0.8.1
cssselect                1.3.0
cssutils                 2.11.1
dataclasses-json         0.6.7
decorator                5.2.1
distro                   1.9.0
einops                   0.8.1
et_xmlfile               2.0.0
fastapi                  0.115.14
filelock                 3.18.0
frozenlist               1.7.0
fsspec                   2025.5.1
ftfy                     6.3.1
future                   1.0.0
GPUtil                   1.4.0
greenlet                 3.2.3
h11                      0.16.0
hf-xet                   1.1.4
httpcore                 1.0.9
httptools                0.6.4
httpx                    0.28.1
httpx-sse                0.4.0
huggingface-hub          0.33.0
idna                     3.10
imagesize                1.4.1
Jinja2                   3.1.6
jiter                    0.10.0
joblib                   1.5.1
jsonpatch                1.33
jsonpointer              3.0.0
langchain                0.3.25
langchain-community      0.3.25
langchain-core           0.3.65
langchain-openai         0.3.24
langchain-text-splitters 0.3.8
langsmith                0.3.45
loguru                   0.7.3
lxml                     5.4.0
MarkupSafe               2.1.5
marshmallow              3.26.1
modelscope               1.31.0
more-itertools           10.7.0
mpmath                   1.3.0
multidict                6.5.0
mypy_extensions          1.1.0
natsort                  8.4.0
networkx                 3.5
numpy                    2.3.0
nvidia-cublas-cu12       12.9.0.13
nvidia-cuda-cccl-cu12    12.9.27
nvidia-cuda-cupti-cu12   12.9.19
nvidia-cuda-nvrtc-cu12   12.9.41
nvidia-cuda-runtime-cu12 12.9.37
nvidia-cudnn-cu12        9.9.0.52
nvidia-cufft-cu12        11.4.0.6
nvidia-cufile-cu12       1.14.0.30
nvidia-curand-cu12       10.3.10.19
nvidia-cusolver-cu12     11.7.4.40
nvidia-cusparse-cu12     12.5.9.5
nvidia-cusparselt-cu12   0.7.1
nvidia-nccl-cu12         2.27.3
nvidia-nvjitlink-cu12    12.9.41
nvidia-nvtx-cu12         12.9.19
openai                   1.88.0
opencv-contrib-python    4.10.0.84
opencv-python-headless   4.11.0.86
openpyxl                 3.1.5
opt-einsum               3.3.0
orjson                   3.10.18
packaging                24.2
paddleocr                3.3.1
paddlepaddle-gpu         3.2.1
paddlex                  3.3.6
pandas                   2.3.0
pillow                   11.2.1
pip                      25.1.1
premailer                3.10.0
prettytable              3.16.0
propcache                0.3.2
protobuf                 6.31.1
psutil                   7.1.3
py-cpuinfo               9.0.0
pyclipper                1.3.0.post6
pycryptodome             3.23.0
pydantic                 2.11.7
pydantic_core            2.33.2
pydantic-settings        2.9.1
pypdfium2                4.30.1
python-bidi              0.6.7
python-dateutil          2.9.0.post0
python-dotenv            1.1.0
pytorch-triton           3.3.1+gitc8757738
pytz                     2025.2
PyYAML                   6.0.2
regex                    2024.11.6
requests                 2.32.4
requests-toolbelt        1.0.0
ruamel.yaml              0.18.14
ruamel.yaml.clib         0.2.12
safetensors              0.6.2.dev0
scikit-learn             1.7.0
scipy                    1.15.3
sentencepiece            0.2.1
setuptools               70.2.0
shapely                  2.1.1
six                      1.17.0
sniffio                  1.3.1
some-package             0.1
soupsieve                2.7
SQLAlchemy               2.0.41
starlette                0.46.2
sympy                    1.14.0
tenacity                 9.1.2
threadpoolctl            3.6.0
tiktoken                 0.9.0
tokenizers               0.21.1
torch                    2.8.0+cu129
torchvision              0.23.0+cu129
tqdm                     4.67.1
triton                   3.4.0
typing_extensions        4.14.0
typing-inspect           0.9.0
typing-inspection        0.4.1
tzdata                   2025.2
ujson                    5.10.0
urllib3                  2.5.0
uvicorn                  0.34.3
uvloop                   0.21.0
watchfiles               1.1.0
wcwidth                  0.2.13
websockets               15.0.1
yarl                     1.20.1
zstandard                0.23.0

🌰 Minimal Reproducible Example (最小可复现问题的Demo)

import os
import time

from natsort import natsorted
from paddleocr import PaddleOCRVL

ocr = PaddleOCRVL(
    layout_detection_model_dir="/mnt/remote/model/.paddlex/official_models/PP-DocLayoutV2",
    vl_rec_model_dir="/mnt/remote/model/.paddlex/official_models/PaddleOCR-VL",
    use_doc_orientation_classify=False,
    use_doc_unwarping=False,
    use_chart_recognition=False,
    enable_mkldnn=True,
    layout_threshold=0.65
)
start_time = time.time()
dir_path = "./_cache/images"
sorted_file = natsorted([
    os.path.join(dir_path, f)
    for f in os.listdir(dir_path)
    if os.path.isfile(os.path.join(dir_path, f))
])
result = ocr.predict_iter(input=sorted_file, use_queues=True)
for idx, res in enumerate(result):
    print(res.json)
end_time = time.time()
duration = end_time - start_time
print(f"Time:[{duration}]")

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions