0

I'm passing a large array (1143, 1252, 365) into skimage.segmentation.slic

It kills jupyter notebook kernel, so I am stuck with the code in pycharm and I get:

Process finished with exit code 139 (interrupted by signal 11: SIGSEGV)

I've tried arrays (1143,1252, 100) and rotated through all the data of the 365 and it works.

I've read that it's a segmentation fault and can be traced with gdb so I have a backtrace from that but it hasn't really helped me

Program received signal SIGSEGV, Segmentation fault.
0x00007fffce88f745 in ?? () from /xxxxxxxxxxpath-removedxxxxxxxxx/_slic.cpython-37m-x86_64-linux-gnu.so

        #0  0x00007fffce88f745 in ?? () from /xxxxxxxxxxpath-removedxxxxxxxxx/python/lib/python3.7/site-packages/skimage/segmentation/_slic.cpython-37m-x86_64-linux-gnu.so
    #1  0x000000000043d587 in _PyMethodDef_RawFastCallKeywords (kwnames=0x0, nargs=0, args=0x8, self=0x0, method=0x7fffcea9f980) at Objects/call.c:694
    #2  _PyCFunction_FastCallKeywords (func=0x7fffcf1c9eb0, args=args@entry=0x224ea80, nargs=nargs@entry=6, kwnames=kwnames@entry=0x0) at Objects/call.c:734
    #3  0x0000000000429681 in call_function (kwnames=0x0, oparg=6, pp_stack=<synthetic pointer>) at Python/ceval.c:4568
    #4  _PyEval_EvalFrameDefault (f=<optimized out>, throwflag=<optimized out>) at Python/ceval.c:3124
    #5  0x00000000004ead18 in PyEval_EvalFrameEx (throwflag=0, f=0x224e800) at Python/ceval.c:547
    #6  _PyEval_EvalCodeWithName (_co=0x7fffcf1c4b70, globals=<optimized out>, locals=locals@entry=0x0, args=<optimized out>, argcount=1, kwnames=0x7ffff7f16a68, kwargs=0x7fffcc562f08, kwcount=3, 
        kwstep=1, defs=0x7fffcf1b7728, defcount=11, kwdefs=0x0, closure=0x0, name=0x7ffff6e05130, qualname=0x7ffff6e05130) at Python/ceval.c:3930
    #7  0x000000000043c9c6 in _PyFunction_FastCallKeywords (func=<optimized out>, stack=<optimized out>, nargs=<optimized out>, kwnames=<optimized out>) at Objects/call.c:433
    #8  0x000000000042880b in call_function (kwnames=0x7ffff7f16a50, oparg=<optimized out>, pp_stack=<synthetic pointer>) at Python/ceval.c:4616
    #9  _PyEval_EvalFrameDefault (f=<optimized out>, throwflag=<optimized out>) at Python/ceval.c:3139
    #10 0x0000000000420668 in function_code_fastcall (co=<optimized out>, args=<optimized out>, nargs=3, globals=<optimized out>) at Objects/call.c:283
    #11 0x000000000043ca9f in _PyFunction_FastCallKeywords (func=<optimized out>, stack=<optimized out>, nargs=<optimized out>, kwnames=<optimized out>) at Objects/call.c:415
    #12 0x000000000042997c in call_function (kwnames=0x0, oparg=<optimized out>, pp_stack=<synthetic pointer>) at Python/ceval.c:4616
    #13 _PyEval_EvalFrameDefault (f=<optimized out>, throwflag=<optimized out>) at Python/ceval.c:3124
    #14 0x0000000000420668 in function_code_fastcall (co=<optimized out>, args=<optimized out>, nargs=0, globals=<optimized out>) at Objects/call.c:283
    #15 0x000000000043ca9f in _PyFunction_FastCallKeywords (func=<optimized out>, stack=<optimized out>, nargs=<optimized out>, kwnames=<optimized out>) at Objects/call.c:415
    #16 0x000000000042997c in call_function (kwnames=0x0, oparg=<optimized out>, pp_stack=<synthetic pointer>) at Python/ceval.c:4616
    #17 _PyEval_EvalFrameDefault (f=<optimized out>, throwflag=<optimized out>) at Python/ceval.c:3124
    #18 0x00000000004ead18 in PyEval_EvalFrameEx (throwflag=0, f=0x7ffff7ee6450) at Python/ceval.c:547
    #19 _PyEval_EvalCodeWithName (_co=_co@entry=0x7ffff6da3ed0, globals=globals@entry=0x7ffff7f65390, locals=locals@entry=0x7ffff6da3ed0, args=args@entry=0x0, argcount=argcount@entry=0, 
        kwnames=kwnames@entry=0x0, kwargs=0x0, kwcount=0, kwstep=2, defs=0x0, defcount=0, kwdefs=0x0, closure=0x0, name=0x0, qualname=0x0) at Python/ceval.c:3930
    #20 0x00000000004eae03 in PyEval_EvalCodeEx (closure=0x0, kwdefs=0x0, defcount=0, defs=0x0, kwcount=0, kws=0x0, argcount=0, args=0x0, locals=locals@entry=0x7ffff6da3ed0, 
        globals=globals@entry=0x7ffff7f65390, _co=_co@entry=0x7ffff6da3ed0) at Python/ceval.c:3959
    #21 PyEval_EvalCode (co=co@entry=0x7ffff6da3ed0, globals=globals@entry=0x7ffff7f4ff00, locals=locals@entry=0x7ffff7f4ff00) at Python/ceval.c:524
    #22 0x00000000005220bf in run_mod (arena=0x7ffff7f65390, flags=0x7fffffffd800, locals=0x7ffff7f4ff00, globals=0x7ffff7f4ff00, filename=0x7ffff7f15f30, mod=0x9c34e0) at Python/pythonrun.c:1035
    #23 PyRun_FileExFlags (fp=0x975850, filename_str=<optimized out>, start=<optimized out>, globals=0x7ffff7f4ff00, locals=0x7ffff7f4ff00, closeit=1, flags=0x7fffffffd800)
        at Python/pythonrun.c:988
    #24 0x00000000005222ec in PyRun_SimpleFileExFlags (fp=0x975850, filename=<optimized out>, closeit=1, flags=0x7fffffffd800) at Python/pythonrun.c:429
    #25 0x0000000000430221 in pymain_run_file (p_cf=0x7fffffffd800, filename=0x91d470 L"tvr.py", fp=0x975850) at Modules/main.c:427
    #26 pymain_run_filename (cf=0x7fffffffd800, pymain=0x7fffffffd910) at Modules/main.c:1606
    #27 pymain_run_python (pymain=0x7fffffffd910) at Modules/main.c:2867
    #28 pymain_main (pymain=pymain@entry=0x7fffffffd910) at Modules/main.c:3028
    #29 0x00000000004304b9 in _Py_UnixMain (argc=<optimized out>, argv=<optimized out>) at Modules/main.c:3063
    #30 0x00007ffff7100830 in __libc_start_main (main=0x4205f0 <main>, argc=2, argv=0x7fffffffda68, init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>, stack_end=0x7fffffffda58)
        at ../csu/libc-start.c:291
    #31 0x000000000042a089 in _start ()

my data is quite sparse if I slice an area with data it looks like this

array_stack[90:110,920:930,1]

array([[       nan,        nan,        nan,        nan,        nan,
        0.02228103, 0.02228103, 0.02228103, 0.02228103, 0.02228103],
       [       nan,        nan,        nan,        nan,        nan,
        0.02240379, 0.02240379, 0.02240379, 0.02240379, 0.02240379],
       [       nan,        nan,        nan,        nan, 0.02252662,
        0.02252662, 0.02252662, 0.02252662, 0.02252662, 0.02252662],
       [       nan,        nan,        nan, 0.02264952, 0.02264952,
        0.02264952, 0.02264952, 0.02264952, 0.02264952, 0.02264952],
       [       nan,        nan,        nan, 0.0227725 , 0.0227725 ,
        0.0227725 , 0.0227725 , 0.0227725 , 0.0227725 , 0.0227725 ],
       [       nan,        nan, 0.02289555, 0.02289555, 0.02289555,
        0.02289555, 0.02289555, 0.02289555, 0.02289555, 0.02289555],
       [       nan,        nan, 0.02301868, 0.02301868, 0.02301868,
        0.02301868, 0.02301868, 0.02301868, 0.02301868, 0.02301868],
       [       nan,        nan, 0.02314188, 0.02314188, 0.02314188,
        0.02314188, 0.02314188, 0.02314188, 0.02314188, 0.02314188],
       [       nan,        nan, 0.02326516, 0.02326516, 0.02326516,
        0.02326516, 0.02326516, 0.02326516, 0.02326516, 0.02326516],
       [       nan,        nan,        nan, 0.02338851, 0.02338851,
        0.02338851, 0.02338851, 0.02338851, 0.02338851, 0.02338851],
       [       nan,        nan,        nan, 0.02351194, 0.02351194,
        0.02351194, 0.02351194, 0.02351194, 0.02351194, 0.02351194],
       [       nan,        nan,        nan,        nan, 0.02363544,
        0.02363544, 0.02363544, 0.02363544, 0.02363544, 0.02363544],
       [       nan,        nan,        nan,        nan,        nan,
               nan, 0.02375902, 0.02375902, 0.02375902, 0.02375902],
       [       nan,        nan,        nan,        nan,        nan,
               nan,        nan,        nan,        nan, 0.02388267],
       [       nan,        nan,        nan,        nan,        nan,
               nan,        nan,        nan,        nan,        nan],
       [       nan,        nan,        nan,        nan,        nan,
               nan,        nan,        nan,        nan,        nan],
       [       nan,        nan,        nan,        nan,        nan,
               nan,        nan,        nan,        nan,        nan],
       [       nan,        nan,        nan,        nan,        nan,
               nan,        nan,        nan,        nan,        nan],
       [       nan,        nan,        nan,        nan,        nan,
               nan,        nan,        nan,        nan,        nan],
       [       nan,        nan,        nan,        nan,        nan,
               nan,        nan,        nan,        nan,        nan]])

and Im calling segmentation like this

from skimage import segmentation as seg

array = seg.slic(array_stack, n_segments = 10000, compactness=0.001, multichannel=True)

I've read that this could be an error in a package I'm using and I may need to log a bug, but I'm not sure how to determine the cause from the backtrace.

Javrel
  • 65
  • 6
  • 3
    How much memory do you have installed in your machine? If my calculation is correct, the array has a size of around 3.9 GiB, and I have seen SIGSEGV happen if memory allocations failed, so this might be a memory-related problem. – Abrixas2 Jan 27 '20 at 22:46
  • 32gb but I have also upped it above that without any change, watchin the mem it only goes to 40% in the system monitor – Javrel Jan 28 '20 at 00:19
  • Try using a smaller sample. Probably 1/100 of the total data and tell us what happens. As @Abrixas2 said it may be a memory issue so you would need to use a batch job. – Edeki Okoh Jan 28 '20 at 00:20
  • Also. What version of python are you using. [Related](https://bugs.python.org/issue34355). [Related](https://stackoverflow.com/questions/59251531/how-to-get-rid-of-process-finished-with-exit-code-139-interrupted-by-signal-11) [Related](https://stackoverflow.com/questions/23704040/exit-code-139-when-performing-image-subtraction) – Edeki Okoh Jan 28 '20 at 00:21
  • This looks like a bug and may be related to having nan's in your data. Could you please create a new issue at https://github.com/scikit-image/scikit-image/issues, and if possible, share your data with us? Thank you! – Juan Jan 28 '20 at 05:27
  • @EdekiOkoh I have already used a smaller batch and it did work, I used array with only 100 in the z Axis and it works but mem usage isnt pushing over 40% and Im using python 3.7.5 – Javrel Jan 28 '20 at 09:19
  • @Juan I will try it without the nans before I create and issue – Javrel Jan 28 '20 at 09:51
  • 1
    @Juan removing the nans has got me moving again, this now makes sence as segmenting with nans is wierd, I was avoiding this prolem before as the arrays were written to tiff where the nan got a value, now I'm dealing with arrays alone this nodata remains at segmentation. Still want me to raise an issue? – Javrel Jan 28 '20 at 10:46
  • Yes, please do, with the smallest array you can find that produces this issue. We should never segfault, even on "funny" data. Thank you! – Juan Jan 29 '20 at 23:58

1 Answers1

0

The problem was caused by NaNs in dataset, it seemed to be fine with smaller arrays that had nans but over a certain size it had a segmentation fault.

Replaced all my nans with a value to represent no data and it worked. Seems like a bug in Scikit image becasue it only happens with larger arrays.

Javrel
  • 65
  • 6