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

Cannot catch MemoryError #7377

Open
dcox1776 opened this issue Apr 9, 2024 · 0 comments
Open

Cannot catch MemoryError #7377

dcox1776 opened this issue Apr 9, 2024 · 0 comments
Labels

Comments

@dcox1776
Copy link

dcox1776 commented Apr 9, 2024

Description:

When running marching_cubes on a stack of large images I encounter MemoryError, Exception ignored in 'skimage.measure._marching_cubes_lewiner_cy.Cell._increase_size_faces'

The error occurs at:
venv\Lib\site-packages\skimage\measure_marching_cubes_lewiner.py", line 181, in _marching_cubes_lewiner
vertices, faces, normals, values = func(volume, level, L,

I have enclosed my call to marching_cubes inside a try except. However, rather than throwing an exception that I can catch, the marching_cubes seems to be stuck in a loop and keeps outputting the following lines:

MemoryError:
MemoryError
Exception ignored in: 'skimage.measure._marching_cubes_lewiner_cy.Cell._increase_size_faces'
Traceback (most recent call last):
File "d:\Development\myproject\venv\Lib\site-packages\skimage\measure_marching_cubes_lewiner.py", line 181, in _marching_cubes_lewiner
vertices, faces, normals, values = func(volume, level, L,
^^^^^^^^^^^^^^^^^^^^^^

Ideally, marching_cubes will manage memory better and not generate these errors. From what I can tell it uses a simple doubling to reserve memory. If this is not possible, then at least throw an exception that can be caught rather than uncontrollably sending these messages.

Way to reproduce:

There is no easy way to reproduce this error. You need a stack of a large number of very large images. For me, I encounter the problem with 1000 images that are 3287 x 2215 16-bit grayscale images running marching_cubes with a step size of 1. My machine has an nvidia 4070ti with 12GB and 128GB of primary memory.

Version information:

>>> import sys; print(sys.version)
3.11.2 (tags/v3.11.2:878ead1, Feb  7 2023, 16:38:35) [MSC v.1934 64 bit (AMD64)]
>>> import platform; print(platform.platform())
Windows-10-10.0.22631-SP0
>>> import skimage; print(f'scikit-image version: {skimage.__version__}')
scikit-image version: 0.22.0
>>> import numpy; print(f'numpy version{numpy.__version__}')
numpy version1.26.4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant