r/rstats • u/New-Jellyfish-9498 • 1d ago
cuplyr 0.2.0: all (except a few weird) dplyr verbs now can be run on the GPU
A while back I posted cuplyr here, a dplyr backend that runs on NVIDIA GPUs. Version 0.2.0 is now out.
All (except a few weird) dplyr verbs now run on the GPU, with the same results as dplyr. One query on 10 million rows has a speedup of 150 times:
> system.time(
+ sales |>
+ mutate(revenue = amount * price) |>
+ arrange(desc(revenue)) |>
+ head(100)
+ )
user system elapsed
0.583 0.052 0.637
> sales_gpu <- tbl_gpu(sales)
> system.time(
+ sales_gpu |>
+ mutate(revenue = amount * price) |>
+ arrange(desc(revenue)) |>
+ head(100) |>
+ collect()
+ )
user system elapsed
0.004 0.000 0.004
The weird verbs are group_map(), group_modify(), group_nest(), nest_by(), nest_join() and do(). They need list columns or arbitrary R functions. Those will then fallback to the CPU.
A new function read_parquet_gpu() reads parquet files straight onto the GPU. The GPU decodes the file, so it uses less RAM than reading it into R first. The reader is lazy too. Put a filter() after it and the filter is pushed down to the Parquet reader, which skips the data it doesn't need.
There's also a conda package now, so no compiler or CUDA toolkit.
No GPU? No worries! This Colab notebook runs it on a free Nvidia T4 GPU.
Found a verb that falls back or a result that differs from dplyr? Open an issue and I'll take a look.
TLDR: cuplyr is at its best on millions of rows, read from Parquet or uploaded once and queried many times. Sorting, string work and group-bys with many groups gain the most.
