You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If one were to interchange with non-cudf dataframes via cudf.core.df_protocol.from_dataframe(), we'd get an error which doesn't quite relate to the problem at hand—that cross-device interchange isn't supported/isn't fully specified.
AttributeErrorTraceback (mostrecentcalllast)
InputIn [4], in<cellline: 1>()
---->1cudf_df=from_dataframe(df)
.../cudf/core/df_protocol.py:658, infrom_dataframe(df, allow_copy)
655ifnothasattr(df, "__dataframe__"):
656raiseValueError("`df` does not support __dataframe__")
-->658return_from_dataframe(df.__dataframe__(allow_copy=allow_copy))
.../cudf/core/df_protocol.py:681, in_from_dataframe(df)
673col=df.get_column_by_name(name)
675ifcol.dtype[0] in (
676_DtypeKind.INT,
677_DtypeKind.UINT,
678_DtypeKind.FLOAT,
679_DtypeKind.BOOL,
680 ):
-->681columns[name], _buf=_protocol_to_cudf_column_numeric(col)
683elifcol.dtype[0] ==_DtypeKind.CATEGORICAL:
684columns[name], _buf=_protocol_to_cudf_column_categorical(col)
.../cudf/core/df_protocol.py:717, in_protocol_to_cudf_column_numeric(col)
715assertbuffers["data"] isnotNone, "data buffer should not be None"716_dbuffer, _ddtype=buffers["data"]
-->717_check_buffer_is_on_gpu(_dbuffer)
718cudfcol_num=build_column(
719Buffer(_dbuffer.ptr, _dbuffer.bufsize),
720protocol_dtype_to_cupy_dtype(_ddtype),
721 )
722return_set_missing_values(col, cudfcol_num), buffers
.../cudf/core/df_protocol.py:728, in_check_buffer_is_on_gpu(buffer)
725def_check_buffer_is_on_gpu(buffer: _CuDFBuffer) ->None:
726if (
727buffer.__dlpack_device__()[0] !=_Device.CUDA-->728andnotbuffer._allow_copy729 ):
730raiseTypeError(
731"This operation must copy data from CPU to GPU. "732"Set `allow_copy=True` to allow it."733 )
735elifbuffer.__dlpack_device__()[0] !=_Device.CUDAandbuffer._allow_copy:
AttributeError: '_VaexBuffer'objecthasnoattribute'_allow_copy'
We get this AttributeError because _check_buffer_is_on_gpu() wants to raise an error when non-CuDF dataframes are being interchanged, but ends up assuming behaviour from CuDF dataframes (specifically buffers) first by using the non-specified attribute _allow_copy
"Only cuDF/GPU dataframes are supported for now. "
"CPU (like `Pandas`) dataframes will be supported shortly."
)
so I imagine desired behaviour here would be to just raise this if buffer doesn't say instance check to _CuDFBuffer.
Assumedly 1) data apis consortium will settle on behaviour 2) cudf adopts it, and thus this is a temporary issue 😅 A fix could be nice in the meantime still, but I namely submit this issue to keep track of things.
The text was updated successfully, but these errors were encountered:
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.
Closes#11245. This PR fixes a bug in our code that consumes a protocol DataFrame that is backed by CPU memory.
This enables using the `from_dataframe()` function to construct DataFrames from other libraries:
```python
In [12]: pdf = pd.DataFrame({'x': [1, 2, 3], 'y': [1.0, 2.0, np.nan], 'z': ['a', 'b', 'c']})
In [13]: vdf = vaex.from_dict({'x': [1, 2, 3], 'y': [1.0, 2.0, np.nan]})
In [14]: cudf.from_dataframe(pdf, allow_copy=True)
Out[14]:
x y z
0 1 1.0 a
1 2 2.0 b
2 3 NaN c
In [15]: cudf.from_dataframe(vdf, allow_copy=True)
Out[15]:
x y
0 1 1.0
1 2 2.0
2 3 NaN
```
Authors:
- Ashwin Srinath (https://github.com/shwina)
- GALI PREM SAGAR (https://github.com/galipremsagar)
- Vyas Ramasubramani (https://github.com/vyasr)
Approvers:
- Bradley Dice (https://github.com/bdice)
- Lawrence Mitchell (https://github.com/wence-)
URL: #11392
If one were to interchange with non-cudf dataframes via
cudf.core.df_protocol.from_dataframe()
, we'd get an error which doesn't quite relate to the problem at hand—that cross-device interchange isn't supported/isn't fully specified.Full traceback
We get this
AttributeError
because_check_buffer_is_on_gpu()
wants to raise an error when non-CuDF dataframes are being interchanged, but ends up assuming behaviour from CuDF dataframes (specifically buffers) first by using the non-specified attribute_allow_copy
cudf/python/cudf/cudf/core/df_protocol.py
Lines 725 to 733 in 4e66281
The method does raise an informative error which I think fits the bill here
cudf/python/cudf/cudf/core/df_protocol.py
Lines 735 to 739 in 4e66281
so I imagine desired behaviour here would be to just raise this if
buffer
doesn't say instance check to_CuDFBuffer
.Assumedly 1) data apis consortium will settle on behaviour 2) cudf adopts it, and thus this is a temporary issue 😅 A fix could be nice in the meantime still, but I namely submit this issue to keep track of things.
The text was updated successfully, but these errors were encountered: