-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
官方样例demo报错: MemoryError: std::bad_alloc #3338
Comments
请提供一下完整的启动命令 |
我来提供一个复现这个问题的方法: 复现过程首先,将以下测试脚本 import paddleclas
model = paddleclas.PaddleClas(model_name="text_image_orientation") 然后,运行以下命令启动docker容器,该容器是一个纯净的Debian Python容器。 docker run --gpus all -it --rm --shm-size=1g -v "/example:/example" python:3.10-slim bash 在容器中、安装必要的依赖项,并运行测试脚本。这里安装的是CPU版本的依赖项,因为目前Paddle的GPU版本和本人使用的其他库不兼容。 # Make the dependencies of OpenCV complete.
apt-get update
apt-get -y install libgomp1 libgl1-mesa-glx libglib2.0-0
# Install PaddleClas
pip install paddlepaddle paddleclas
# Run the test.
cd /example
python test.py 报错结果于是,得到以下报错: [2025/01/15 20:08:51] ppcls INFO: download https://paddleclas.bj.bcebos.com/models/PULC/inference/text_image_orientation_infer.tar to /root/.paddleclas/inference_model/PULC/text_image_orientation/text_image_orientation_infer.tar
100%|████████████████████████████████████████████████████████████████████████████| 7.40M/7.40M [00:18<00:00, 402kiB/s]
[2025/01/15 20:09:12] ppcls WARNING: The current running environment does not support the use of GPU. CPU has been used instead.
Traceback (most recent call last):
File "/example/test.py", line 3, in <module>
model = paddleclas.PaddleClas(model_name="text_image_orientation")
File "/usr/local/lib/python3.10/site-packages/paddleclas/paddleclas.py", line 610, in __init__
self.predictor = ClsPredictor(self._config)
File "/usr/local/lib/python3.10/site-packages/paddleclas/deploy/python/predict_cls.py", line 28, in __init__
super().__init__(config["Global"])
File "/usr/local/lib/python3.10/site-packages/paddleclas/deploy/utils/predictor.py", line 37, in __init__
self.predictor, self.config = self.create_paddle_predictor(
File "/usr/local/lib/python3.10/site-packages/paddleclas/deploy/utils/predictor.py", line 108, in create_paddle_predictor
predictor = create_predictor(config)
MemoryError: std::bad_alloc 深入测试是shared memory的问题吗?有没有可能,是shared memory太小?我尝试将container的启动参数改为: docker run --gpus all -it --rm --shm-size=16g -v "/example:/example" python:3.10-slim bash 这个大小已经比教程里还大了。 然而错误如故。 是因为使用了GPU映射的关系吗?尝试将 docker run -it --rm --shm-size=1g -v "/example:/example" python:3.10-slim bash 然而错误如故。 是paddlepaddle的安装有问题、或是因为paddlepaddle的CPU版本不可用吗?我刚好知道NVIDIA有一个paddlepaddle的镜像,透过尝试运行它,并重复上述测试, docker run --gpus all -it --rm --shm-size=1g -v "/example:/example" nvcr.io/nvidia/paddlepaddle:24.10-py3 为什么要用 注意由于镜像里已经有了GPU版本的paddlepaddle-gpu,安装过程需要修改一下: # Make the dependencies of OpenCV complete.
# Note that this is an Ubuntu image.
apt-get update
apt-get -y install libgomp1 libegl1 libglu1-mesa-dev
# Do not need to install paddlepaddle because paddlepaddle-gpu already exists.
pip install paddleclas
# Run the test.
cd /example
python test.py 这回依然报错,但是报错的内容不一样了 [2025/01/15 20:46:49] ppcls INFO: download https://paddleclas.bj.bcebos.com/models/PULC/inference/text_image_orientation_infer.tar to /root/.paddleclas/inference_model/PULC/text_image_orientation/text_image_orientation_infer.tar
100%|██████████████████████████████████████████████████████████████████████████████| 7.40M/7.40M [00:18<00:00, 406kiB/s]
Traceback (most recent call last):
File "/example/test.py", line 3, in <module>
model = paddleclas.PaddleClas(model_name="text_image_orientation")
File "/usr/local/lib/python3.10/dist-packages/paddleclas/paddleclas.py", line 610, in __init__
self.predictor = ClsPredictor(self._config)
File "/usr/local/lib/python3.10/dist-packages/paddleclas/deploy/python/predict_cls.py", line 28, in __init__
super().__init__(config["Global"])
File "/usr/local/lib/python3.10/dist-packages/paddleclas/deploy/utils/predictor.py", line 37, in __init__
self.predictor, self.config = self.create_paddle_predictor(
File "/usr/local/lib/python3.10/dist-packages/paddleclas/deploy/utils/predictor.py", line 108, in create_paddle_predictor
predictor = create_predictor(config)
ValueError: basic_string::_M_replace_aux 使用官方的
|
感谢您的反馈和非常详细的实验!我们会安排排查该问题。 |
赞!很详细的解决方案,我尝试把paddlepaddle版本回退,确实成功运行! |
可见paddle相关库在发布的时候,并没有自动化运行各种测试样例的机制。 |
直接按官方样例demo写的
python run.py
2025-01-03 18:29:51 INFO: Loading faiss with AVX512 support.
2025-01-03 18:29:51 INFO: Successfully loaded faiss with AVX512 support.
[2025/01/03 18:29:51] ppcls WARNING: The current running environment does not support the use of GPU. CPU has been used instead.
Traceback (most recent call last):
File "run.py", line 2, in
model = paddleclas.PaddleClas(model_name="person_attribute")
File "venv/lib/python3.8/site-packages/paddleclas/paddleclas.py", line 610, in init
self.predictor = ClsPredictor(self._config)
File "venv/lib/python3.8/site-packages/paddleclas/deploy/python/predict_cls.py", line 28, in init
super().init(config["Global"])
File "venv/lib/python3.8/site-packages/paddleclas/deploy/utils/predictor.py", line 37, in init
self.predictor, self.config = self.create_paddle_predictor(
File "venv/lib/python3.8/site-packages/paddleclas/deploy/utils/predictor.py", line 108, in create_paddle_predictor
predictor = create_predictor(config)
MemoryError: std::bad_alloc
The text was updated successfully, but these errors were encountered: