pitrou commented on code in PR #40385:
URL: https://github.com/apache/arrow/pull/40385#discussion_r1556047798
##########
python/pyarrow/lib.pyx:
##########
@@ -143,6 +144,18 @@ def _pac():
return __pac
+def _ensure_cuda_loaded():
+ # Try importing the cuda module to ensure libarrow_cuda gets loaded
+ # to register the CUDA device for the C Data Interface import
+ global __cuda_loaded
+ if not __cuda_loaded:
+ try:
+ import pyarrow.cuda # no-cython-lint
+ except ImportError:
+ pass
Review Comment:
Do we really want to silence the error? The error message could be more
informative than the error the user would later get when a device array fails
importing...
##########
python/pyarrow/array.pxi:
##########
@@ -1835,23 +1835,25 @@ cdef class Array(_PandasConvertible):
This is a low-level function intended for expert users.
"""
cdef:
- void* c_ptr = _as_c_pointer(in_ptr)
+ ArrowDeviceArray* c_device_array =
<ArrowDeviceArray*>_as_c_pointer(in_ptr)
void* c_type_ptr
shared_ptr[CArray] c_array
+ if c_device_array.device_type == 2:
Review Comment:
We could perhaps instead add `kDLCUDA` to
https://github.com/apache/arrow/blob/f8784acbfcd4a2811dd404d4d53a89b26569b05a/python/pyarrow/includes/libarrow.pxd#L1322-L1323
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]