Skip to content

labels_to_contours selects CuPy/Dask backend and crashes inside scikit-image #231

@Erwin-Jo

Description

@Erwin-Jo

Hi Ultrack team,

first I want to say my thanks for the awesome software.

On Ultrack version 0.6.3, calling ultrack.utils.edge.labels_to_contours(...) with NumPy label stacks on a machine/ JupyterHub cluter where CuPy is available (or when inputs originate from Dask with GPU meta data) causes Ultrack to choose the CuPy array backend internally. The function subsequently calls scikit-image/SciPy CPU-only morphology routines, which attempt to coerce a cupy.ndarray to NumPy and fail with:

TypeError: Implicit conversion to a NumPy array is not allowed. Please use .get() to construct a NumPy array explicitly.

It occurs despite calling compute() on a dask.array or creating a fresh sample Numpy.ndarray. This error is quite persistent and the only round away solution I found is to put the following before labels_to_contours:

import ultrack.utils.edge as edge
edge.xp = np

I wanted to bring this bug to your attention to know if there is a better way to circumvent this problem and understand what is the cause behind it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions