Skip to content

NEP-18: Calls on Dask+CuPy arrays cause "object __array__ method not producing an array" #4563

@pentschev

Description

@pentschev

Consider the following example:

import numpy as np
import cupy
import dask.array as da

x = cupy.random.random((5000, 1000))

d = da.from_array(x, chunks=(1000, 1000), asarray=False)

u, s, v = np.linalg.svd(d)

This gives the following traceback:

Traceback (most recent call last):
  File "svd.py", line 9, in <module>
    u, s, v = np.linalg.svd(d)
  File "/home/pentschev/.local/lib/python3.5/site-packages/numpy/core/overrides.py", line 152, in public_api
    implementation, public_api, relevant_args, args, kwargs)
  File "/home/pentschev/.local/lib/python3.5/site-packages/numpy/linalg/linalg.py", line 1598, in svd
    a, wrap = _makearray(a)
  File "/home/pentschev/.local/lib/python3.5/site-packages/numpy/linalg/linalg.py", line 117, in _makearray
    new = asarray(a)
  File "/home/pentschev/.local/lib/python3.5/site-packages/numpy/core/overrides.py", line 152, in public_api
    implementation, public_api, relevant_args, args, kwargs)
  File "/home/pentschev/.local/lib/python3.5/site-packages/numpy/core/numeric.py", line 555, in asarray
    return array(a, dtype, copy=False, order=order)
  File "/home/pentschev/.local/lib/python3.5/site-packages/dask/array/core.py", line 1002, in __array__
    x = np.array(x)
ValueError: object __array__ method not producing an array

I don't immediately see what's the cause for this issue. In this last function of the trace above, x is a CuPy array. Is that the case that we should add explicit support for __array_function__ in Dask Array?

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