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

[FEA] Supporting cuDF Series in device_array_like #129

Closed
jakirkham opened this issue Sep 11, 2019 · 6 comments
Closed

[FEA] Supporting cuDF Series in device_array_like #129

jakirkham opened this issue Sep 11, 2019 · 6 comments
Labels
feature request New feature or request

Comments

@jakirkham
Copy link
Member

jakirkham commented Sep 11, 2019

Is your feature request related to a problem? Please describe.

I'd like to run the following code.

from librmm_cffi import librmm as rmm
import cudf

s = cudf.Series([0, 1, 2])
a = rmm.device_array_like(s)

Currently this fails with the following error.

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-3-917a74c3463e> in <module>
----> 1 rmm.device_array_like(s)

~/miniconda/envs/rapids9/lib/python3.7/site-packages/librmm_cffi/wrapper.py in device_array_like(self, ary, stream)
    227             ary = ary.reshape(1)
    228 
--> 229         return self.device_array(ary.shape, ary.dtype, ary.strides,
    230                                  stream=stream)
    231 

AttributeError: 'Series' object has no attribute 'strides'

Describe the solution you'd like

It would be great if rmm.device_array_like worked with Series objects. No strong feelings about how that is accomplished.

Describe alternatives you've considered

We could special case handling of Series objects, but this shifts the burden to other libraries to solve this problem.

Alternatively cuDF Series objects could gain a strides attribute. This could be reasonable.

Additional context

This came up when trying to better handle GPU array-like objects in cuML ( rapidsai/cuml#1086 ), which is part of the Grid Search effort.

Edit: More specifically, we tried to use librmm_cffi.librmm.to_device instead of numba.cuda.to_device, but were unable to as Series are not supported.

@jakirkham
Copy link
Member Author

Hmm...the doc label here is a bit unexpected. Unfortunately I don't seem able to fix that. Should be flagged as an enhancement or possibly a bug depending.

@jakirkham
Copy link
Member Author

FWIW if I perform this operation with Numba's to_device, it works without issues.

import numba
import numba.cuda

numba.cuda.to_device(s)

cc @kkraus14 ( in response to this comment rapidsai/cuml#1086 (comment) )

@kkraus14
Copy link
Contributor

kkraus14 commented Sep 11, 2019

I'm guessing numba is using __cuda_array_interface__ here, whereas RMM doesn't since it assumes it should allocate memory.

EDIT: yup

In [28]: cuda.to_device(s).device_ctypes_pointer.value
Out[28]: 139706211778048

In [29]: s.data.mem.device_ctypes_pointer.value
Out[29]: 139706211778048

@kkraus14 kkraus14 added feature request New feature or request and removed doc Documentation labels Sep 11, 2019
@jakirkham
Copy link
Member Author

Yeah that makes sense. Using __cuda_array_interface__ here would be great (assuming others agree).

@kkraus14
Copy link
Contributor

kkraus14 commented Jan 7, 2020

Removing array functionality in RMM in future so closing this issue.

@kkraus14 kkraus14 closed this as completed Jan 7, 2020
@jakirkham
Copy link
Member Author

For future readers, please see issue ( #180 ) for context.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants