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

[BUG] CumlArray error while handling empty cupy array #4095

Open
tfeher opened this issue Jul 26, 2021 · 2 comments
Open

[BUG] CumlArray error while handling empty cupy array #4095

tfeher opened this issue Jul 26, 2021 · 2 comments
Labels
? - Needs Triage Need team to review and classify bug Something isn't working inactive-30d inactive-90d

Comments

@tfeher
Copy link
Contributor

tfeher commented Jul 26, 2021

Describe the bug
CumlArray has a problem while wrapping empty cupy array. Depending on where the array has 0 dim, we can run into the following exception:

Steps/Code to reproduce bug
Used 21.08 nightly to test (rapidsai/rapidsai-core-dev-nightly:21.08-cuda11.2-devel-ubuntu18.04-py3.8 on V100-SXM2-16GB, driver 460.32.03).

import cupy as cp
from cuml.common.array import CumlArray
dtype = cp.float32

# This works
x = cp.empty(shape=(0, 1), dtype=dtype, order='F')
x_cp = cp.asarray(x)

# This also works
x = CumlArray.empty(shape=(1, 0), dtype=dtype, order='F')
x_cp = cp.asarray(x) 

# This does not work
x = CumlArray.empty(shape=(0, 1), dtype=dtype, order='F')
x_cp = cp.asarray(x)

Output:

---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
<ipython-input-3-71e2f5f68c60> in <module>
     13 # This does not work
     14 x = CumlArray.empty(shape=(0, 1), dtype=dtype, order='F')
---> 15 x_cp = cp.asarray(x)

/opt/conda/envs/rapids/lib/python3.8/site-packages/cupy/_creation/from_data.py in asarray(a, dtype, order)
     64 
     65     """
---> 66     return _core.array(a, dtype, False, order)
     67 
     68 

cupy/_core/core.pyx in cupy._core.core.array()

cupy/_core/core.pyx in cupy._core.core.array()

cupy/_core/core.pyx in cupy._core.core._convert_object_with_cuda_array_interface()

cupy/cuda/memory.pyx in cupy.cuda.memory.UnownedMemory.__init__()

RuntimeError: UnownedMemory requires explicit device ID for a null pointer.

Expected behavior
Return an empty cupy array in all cases, without error.

Additional context
This problem can be triggered if a model has parameter arrays with zero size (see #4033). (Admittedly it is a rare case.)

@tfeher tfeher added bug Something isn't working ? - Needs Triage Need team to review and classify labels Jul 26, 2021
@github-actions
Copy link

This issue has been labeled inactive-90d due to no recent activity in the past 90 days. Please close this issue if no further response or action is needed. Otherwise, please respond with a comment indicating any updates or changes to the original issue and/or confirm this issue still needs to be addressed.

@github-actions
Copy link

This issue has been labeled inactive-30d due to no recent activity in the past 30 days. Please close this issue if no further response or action is needed. Otherwise, please respond with a comment indicating any updates or changes to the original issue and/or confirm this issue still needs to be addressed. This issue will be labeled inactive-90d if there is no activity in the next 60 days.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
? - Needs Triage Need team to review and classify bug Something isn't working inactive-30d inactive-90d
Projects
None yet
Development

No branches or pull requests

1 participant