cuDF is a GPU DataFrame library that provides a pandas-like API for GPU-accelerated data manipulation. Part of NVIDIA RAPIDS, it enables 10-100x speedups for data processing.
CUDA Integration: cuDF stores data in GPU memory using Apache Arrow format. Operations are executed as CUDA kernels, with automatic memory management and optional spill-to-host for large datasets.
Install via conda.
conda create -n cudf -c rapidsai -c conda-forge -c nvidia cudf=24.02 python=3.10 cuda-version=12.0
conda activate cudf
import cudf; print(cudf.__version__)Using cuDF like pandas.
import cudf
import pandas as pd
# Create from dict
gdf = cudf.DataFrame({'a': [1, 2, 3], 'b': [4, 5, 6]})
# From pandas
pdf = pd.DataFrame({'x': range(1000)})
gdf = cudf.from_pandas(pdf)
# Operations
result = gdf.groupby('a').mean()
filtered = gdf[gdf['a'] > 1]
merged = gdf.merge(other_gdf, on='key')Complete data processing pipeline.
import cudf
import dask_cudf
# Read large dataset
gdf = cudf.read_parquet('data/*.parquet')
# Clean
gdf = gdf.dropna()
gdf['date'] = cudf.to_datetime(gdf['timestamp'])
# Feature engineering
gdf['day_of_week'] = gdf['date'].dt.dayofweek
gdf['rolling_mean'] = gdf.groupby('category')['value'].transform('mean')
# Aggregate
result = gdf.groupby(['category', 'day_of_week']).agg({
'value': ['mean', 'std', 'count']
})
# To pandas for visualization
pdf = result.to_pandas()Parquet is columnar, much faster to read.
Avoid intermediate DataFrames.
Lower memory, faster groupby.
cudf.set_option("spill", True) for OOM.
| Task | Performance | Notes |
|---|---|---|
| Read Parquet | 5-10x vs pandas | Depends on data |
| GroupBy | 20-100x | Many groups |
| Join | 10-50x | Large tables |
Most, but not all. Check API docs.
Use spill option or Dask-cuDF for multi-GPU.
Convert to pandas first, or use cuML.
Optimize your cuDF CUDA code with RightNow AI - get real-time performance suggestions and memory analysis.