cucim icon indicating copy to clipboard operation
cucim copied to clipboard

Use SciPy's KDTree instead of deprecated cKDTree

Open grlee77 opened this issue 9 months ago • 1 comments

Functionality is equivalent since SciPy 1.6 (see note here).

I pinned SciPy to >= 1.6 (released Dec 31, 2020)

This MR also adds some missing test cases for the _ensure_spacing helper function used by cucim.skimage.feature.peak_local_max. The new tests revealed a bug in that function in the case of non-scalar spacing which is now fixed.

Also, CuPy recently added KDTree so we can hopefully improve performance by moving to that in the future. I opened issue #732 as a reminder to investigate that.

grlee77 avatar Apr 27 '24 15:04 grlee77

Some nvjitlink-related failure occurs in CuPy for the conda test cases. Not sure if it is related to the recent CuPy 13.1.0 release or some other cause.

Failures have the following form

2024-04-27T16:07:59.3287426Z =================================== FAILURES ===================================
2024-04-27T16:07:59.3289101Z _____________________________ test_2d_bf[float16] ______________________________
2024-04-27T16:07:59.3291152Z [gw4] linux -- Python 3.11.9 /opt/conda/envs/test/bin/python3.11
2024-04-27T16:07:59.3294929Z src/cucim/skimage/segmentation/tests/test_random_walker.py:84: in test_2d_bf
2024-04-27T16:07:59.3298859Z     labels_bf = random_walker(data, labels, beta=beta, mode="bf")
2024-04-27T16:07:59.3302302Z /opt/conda/envs/test/lib/python3.11/site-packages/cucim/skimage/_shared/utils.py:343: in fixed_func
2024-04-27T16:07:59.3305252Z     return func(*args, **kwargs)
2024-04-27T16:07:59.3308472Z /opt/conda/envs/test/lib/python3.11/site-packages/cucim/skimage/segmentation/random_walker_segmentation.py:523: in random_walker
2024-04-27T16:07:59.3311391Z     lap_sparse, B = _build_linear_system(
2024-04-27T16:07:59.3315377Z /opt/conda/envs/test/lib/python3.11/site-packages/cucim/skimage/segmentation/random_walker_segmentation.py:154: in _build_linear_system
2024-04-27T16:07:59.3318342Z     lap_sparse = _build_laplacian(
2024-04-27T16:07:59.3321328Z /opt/conda/envs/test/lib/python3.11/site-packages/cucim/skimage/segmentation/random_walker_segmentation.py:132: in _build_laplacian
2024-04-27T16:07:59.3324390Z     lap = lap.tocsr()
2024-04-27T16:07:59.3326431Z /opt/conda/envs/test/lib/python3.11/site-packages/cupyx/scipy/sparse/_coo.py:527: in tocsr
2024-04-27T16:07:59.3328453Z     from cupyx import cusparse
2024-04-27T16:07:59.3330416Z /opt/conda/envs/test/lib/python3.11/site-packages/cupyx/cusparse.py:9: in <module>
2024-04-27T16:07:59.3333594Z     from cupy_backends.cuda.libs import cusparse as _cusparse
2024-04-27T16:07:59.3337828Z E   ImportError: libnvJitLink.so.12: cannot open shared object file: No such file or directory

grlee77 avatar Apr 27 '24 16:04 grlee77

After offline discussion, think this was an issue in the CuPy packages that was fixed recently with PR: https://github.com/conda-forge/cupy-feedstock/pull/269

Restarting CI

jakirkham avatar Apr 29 '24 18:04 jakirkham

| After offline discussion, think this was an issue in the CuPy packages that was fixed recently with PR: https://github.com/conda-forge/cupy-feedstock/pull/269

Was just going to ping you and ask, but saw you already resolved the issue. Thanks @jakirkham!

grlee77 avatar Apr 29 '24 21:04 grlee77

Yes Greg could you please update these lines?

https://github.com/rapidsai/cucim/blob/edd1da3d8c83f6711cd57250ac3e3be1ff636998/conda/recipes/cucim/meta.yaml#L69

https://github.com/rapidsai/cucim/blob/edd1da3d8c83f6711cd57250ac3e3be1ff636998/conda/recipes/cucim/meta.yaml#L82

jakirkham avatar Apr 30 '24 15:04 jakirkham

@raydouglass , @jakirkham : Thanks, I have now updated the pinning in the conda recipe

grlee77 avatar Apr 30 '24 17:04 grlee77

/merge

jakirkham avatar Apr 30 '24 18:04 jakirkham

Thanks Greg and Ray! 🙏

jakirkham avatar Apr 30 '24 18:04 jakirkham