I'm interested in recommended and fast ways of creating cudf DataFrames from dense numpy objects. I have seen many examples of splitting out columns of a 2d numpy matrix to tuples then calling cudf.DataFrame
on a list of tuples -- this is rather expensive. Using numba.cuda.to_device
is quite fast. Is it possible to use numba.cuda.to_device
or is there a more efficient way of constructing the DataFrame ?
In [1]: import cudf
In [2]: import numba.cuda
In [3]: import numpy as np
In [4]: data = np.random.random((300,100))
In [5]: data.nbytes
Out[5]: 240000
In [6]: %time numba.cuda.to_device(data)
CPU times: user 8 ms, sys: 0 ns, total: 8 ms
Wall time: 4.45 ms
Out[6]: <numba.cuda.cudadrv.devicearray.DeviceNDArray at 0x7f8954f84550>
In [7]: record_data = (('fea%d'%i, data[:,i]) for i in range(data.shape[1]))
In [8]: %time cudf.DataFrame(record_data)
CPU times: user 960 ms, sys: 508 ms, total: 1.47 s
Wall time: 1.61 s
Out[8]: <cudf.DataFrame ncols=100 nrows=300 >
The above shows cudf.DataFrame
~360x slower than a direct call to numba.cuda.to_device