packages icon indicating copy to clipboard operation
packages copied to clipboard

Package issue: most opencv builds fail because of out of memory errors

Open LivingWithHippos opened this issue 10 months ago • 5 comments

Package name

opencv-contrib-python

Package version

all

PyPI URL

https://pypi.org/project/opencv-contrib-python/

piwheels URL

https://www.piwheels.org/project/opencv-contrib-python/

Python version

  • [x] Python 3.9
  • [x] Python 3.11

I am aware this is the issue tracker for a Python package index specifically for Raspberry Pi

  • [x] Yes

I have checked for duplicate issues

  • [x] Yes

I am the maintainer

  • [ ] Yes

More information

There are 4 packages related to opencv:

  • opencv-contrib-python (the heaviest to compile)
  • opencv-contrib-python-headless
  • opencv-python
  • opencv-python-headless

most of these fails because of out of memory errors

2025-01-16T17:27:43,990   virtual memory exhausted: Cannot allocate memory
2025-01-16T17:27:43,990   ninja: build stopped: subcommand failed.
2025-01-16T17:27:43,997   Traceback (most recent call last):
2025-01-16T17:27:44,001     File "/tmp/pip-build-env-dz4z37a7/overlay/lib/python3.9/site-packages/skbuild/setuptools_wrap.py", line 668, in setup
2025-01-16T17:27:44,002       cmkr.make(make_args, install_target=cmake_install_target, env=env)
2025-01-16T17:27:44,002     File "/tmp/pip-build-env-dz4z37a7/overlay/lib/python3.9/site-packages/skbuild/cmaker.py", line 696, in make
2025-01-16T17:27:44,002       self.make_impl(clargs=clargs, config=config, source_dir=source_dir, install_target=install_target, env=env)
2025-01-16T17:27:44,002     File "/tmp/pip-build-env-dz4z37a7/overlay/lib/python3.9/site-packages/skbuild/cmaker.py", line 741, in make_impl
2025-01-16T17:27:44,002       raise SKBuildError(msg)

the solution should be to enable a bigger swap size setting CONF_SWAPSIZE=4GB into /etc/dphys-swapfile and loading the setting with /etc/init.d/dphys-swapfile restart

Thanks for all your work, these are pretty common libraries and having them working without a compilation step would be great.

LivingWithHippos avatar Feb 20 '25 14:02 LivingWithHippos

Any news on this issue?

gusmig avatar Nov 03 '25 16:11 gusmig

The latest comment on this is https://github.com/piwheels/packages/issues/299#issuecomment-3403120658

bennuttall avatar Nov 03 '25 20:11 bennuttall

I don't know how the raspberry environment is managed, but maybe just asking them to set these settings could be enough? I suppose they have an image or something if it's not directly managed by piwheels Thanks for your hard work btw

LivingWithHippos avatar Nov 06 '25 12:11 LivingWithHippos

Asking who?

We configure a swapfile on builders but it's only 1GB. Maybe bumping to the RAM size will help. I'll check with @waveform80.

bennuttall avatar Nov 06 '25 13:11 bennuttall

Sorry I must have misread the other answer. Bumping the swap to 4GB with the commands above worked for me on a CM3

LivingWithHippos avatar Nov 06 '25 13:11 LivingWithHippos