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

2.8.0~2.9.0显存占用大大超出2.7.3 #14053

Open
3 tasks done
myhloli opened this issue Oct 21, 2024 · 6 comments
Open
3 tasks done

2.8.0~2.9.0显存占用大大超出2.7.3 #14053

myhloli opened this issue Oct 21, 2024 · 6 comments

Comments

@myhloli
Copy link
Contributor

myhloli commented Oct 21, 2024

🔎 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 (问题描述)

今天更新了2.9.0版本测试,发现rec过程显存占用比2.7.3超出几倍不止,直接爆了3060ti的8g显存
回测了之前的版本发现2.8.0,2.8.1存在同样的问题

看了下默认的参数rec_batch_num=6,

在2.7.3版本改动这个值不会影响显存占用,可能是batch不生效?峰值占用约1.7G,改成1之后也是这个占用,改成10也一样

在2.8.0/2.8.1/2.9.0表现一致,占用7G左右。

将rec_batch_num改成1,在2.8.0/2.8.1/2.9.0占用可以降到2.6G,远超出2.7.3的1.7G占用

rec模型都是一样的ch_PP-OCRv4_rec_infer,只是改变paddleocr的版本,就能测试出明显的显存占用差异
框架是使用的同样的paddlepaddle-gpu 2.6.1版本,希望可以排查下2.8+在单个rec batch多占用的900m显存的原因

🏃‍♂️ Environment (运行环境)

windows 11
paddlepaddle-gpu 2.6.1
cuda 11.8
gpu 3060ti
vram 8g
paddleocr 2.7.3/2.8.0/2.8.1/2.9.0

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

import os
import time
from paddleocr import PaddleOCR

ocr = PaddleOCR(rec_batch_num=1)

def extract_text_from_images(directory):
    results = {}
    # 遍历目录中的所有文件
    for filename in os.listdir(directory):
        if filename.endswith(".jpg"):
            filepath = os.path.join(directory, filename)
            # 读取图像并进行OCR识别
            result = ocr.ocr(filepath, cls=True)
            # 提取识别结果中的文本
            text = [line[1][0] for line in result[0]]
            results[filename] = ' '.join(text)
    return results

# 使用函数
directory_path = "E:\pdf_meta\demo\ocr_test"  #  目录里只需要放几张文本量不大的书籍页面截图即可复现
start_time = time.time()
texts = extract_text_from_images(directory_path)
for img_name, text in texts.items():
    print(f"Image: {img_name}, Text: {text}")

end_time = time.time()

print(f"Total time taken: {end_time - start_time} seconds")
@GreatV
Copy link
Collaborator

GreatV commented Oct 22, 2024

paddle框架换成3.0呢

@myhloli
Copy link
Contributor Author

myhloli commented Oct 22, 2024

paddle框架换成3.0呢

换3.0之后显存超高占用的问题解决了,目前有个问题是pypi上没有windows版本的paddlepaddle(cpu)3.0包,目前如果需要同时安装cpu版本和gpu版本的paddle框架的话,是否需要使用统一的版本,比如都用2.6.1或者都用3.0.0b1

@GreatV
Copy link
Collaborator

GreatV commented Oct 22, 2024

@myhloli paddle框架似乎改成了自己 host python package,参考 https://www.paddlepaddle.org.cn/install/quick?docurl=/documentation/docs/zh/develop/install/pip/windows-pip.html

@myhloli
Copy link
Contributor Author

myhloli commented Oct 22, 2024

我测试了在windows先安装2.6.1版本的paddlepaddle,跑同一个任务用时26秒,再安装3.0.0b1的paddlepaddle-gpu,use_gpu=True可以正常运行,但是use_gpu=False时,同一个任务耗时变成了62秒,好像时gpu版本的paddle框架内置了cpu版本,3.0版本的框架cpu性能下降严重的问题一并带进来了。所以应该在3.0版本解决cpu性能问题前在windows上留守2.6版本

@GreatV
Copy link
Collaborator

GreatV commented Oct 22, 2024

是不是跟cpu指令集有关,对于nonavx512可能会有性能下降。

@myhloli
Copy link
Contributor Author

myhloli commented Oct 22, 2024

是不是跟cpu指令集有关,对于nonavx512可能会有性能下降。

测试设备是12代i7,应该是没有avx512的,但是cpu版本在2.6.1就是正常的

在paddle仓库提了issue:PaddlePaddle/Paddle#66697
应该是3.0框架的bug

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