Skip to contents

cuplyr runs dplyr code on an NVIDIA GPU. It is a dplyr backend, like dbplyr, built on RAPIDS cuDF. Upload a data frame with tbl_gpu(), use the dplyr verbs you already know, and collect() the result back into R.

library(cuplyr)
library(dplyr)

set.seed(1)
n <- 1e5
sales <- data.frame(
  year    = sample(2018:2024, n, replace = TRUE),
  region  = sample(c("north", "south", "east", "west"), n, replace = TRUE),
  quarter = sample(1:4, n, replace = TRUE),
  amount  = rnorm(n, mean = 50, sd = 30),
  price   = runif(n, 1, 10)
)
regions <- data.frame(
  region  = c("north", "south", "east", "west"),
  manager = c("Ana", "Ben", "Chi", "Dev")
)

tbl_gpu(sales) |>
  filter(year >= 2020, amount > 0) |>
  mutate(revenue = amount * price) |>
  group_by(region, quarter) |>
  summarise(total = sum(revenue), .groups = "drop") |>
  inner_join(tbl_gpu(regions), by = "region") |>
  arrange(desc(total)) |>
  collect()

No GPU? The Colab notebook installs cuplyr on a free T4 and runs a few pipelines.

cuplyr is experimental. Expect breaking changes before 1.0.

What runs on the GPU

The goal is every dplyr verb, with dplyr’s results. Any difference from dplyr is a bug. The test suite checks cuplyr against dplyr, including dplyr’s own tests.

These run on the GPU:

Anything else falls back to the CPU. cuplyr collects the data, runs dplyr and uploads the result. Your code still works, but the data makes a round trip. The fallback is silent by default. Set options(cuplyr.fallback = "warn") to see each fallback with its expression and reason, or "error" to forbid them.

Column types:

R GPU
logical BOOL8
integer INT32
double FLOAT64
character STRING
factor DICTIONARY32, levels kept
Date TIMESTAMP_DAYS
POSIXct TIMESTAMP_MICROSECONDS, time zone kept
integer64 INT64, exact; collect() gives back bit64::integer64

Not supported: list columns, other column classes and more than one GPU. Uploading a difftime, hms or ts column raises an error. The open issues track what is planned, in priority order on the roadmap board.

Lazy by default

tbl_gpu() is lazy. Each verb checks its arguments and records a step, so a typo or type error still fails at the verb that caused it. Nothing runs until you collect() the result into R or compute() it into a table that stays on the GPU. Then cuplyr optimizes the whole plan, runs it and frees every intermediate column.

Printing a lazy table runs the plan to show the first rows and keeps nothing. Print it twice and it runs twice. compute() a table you want to look at often.

explain() prints the plan the optimizer will run as R code: the steps in order, the columns each source reads, and any step that fell back to the CPU, with the reason. show_query(optimized = FALSE) prints the steps as you wrote them. Neither runs anything:

tbl_gpu(mtcars) |>
  filter(mpg > 20) |>
  mutate(kpl = mpg * 0.425) |>
  select(cyl, kpl) |>
  explain()

The optimizer drops columns the result never reads, fuses consecutive mutate() calls, pushes filters below mutates, selects and some joins, and merges consecutive filters into one. vignette("query-optimization") describes each pass.

For a single pipeline, lazy is as fast as eager up to 1e6 rows and under a millisecond slower at 1e7. In exchange it holds no GPU memory between calls. Eager mode keeps intermediate results on the GPU until R’s next gc(), and in a loop they fill the card. Over 5e7 rows, five back-to-back eager runs took 68 ms each. Lazy took 18 ms.

Eager mode runs each verb as soon as you call it, which is easier when you step through code by hand:

tbl_gpu(mtcars, lazy = FALSE)          # one table
options(cuplyr.exec_mode = "eager")    # every table created afterwards

cuplyr_options() lists the other options.

Performance

A five-verb pipeline (filter, mutate, group_by, summarise, arrange) on an RTX 5070, median ms per call:

rows cuplyr, lazy dplyr
1e3 1.75 3.50
1e6 2.00 22.0
1e7 5.00 213

The GPU loses when you upload a table, run one cheap verb and collect it. Uploading 1e7 rows takes 63 ms and collecting them takes 54 ms. Keep data on the GPU between steps and collect once at the end.

vignette("performance") has the method, eager timings, memory per call and the other cases where dplyr wins. vignette("memory") explains how cuplyr allocates GPU memory and when gpu_gc() gives it back.

Installation

The conda and pixi package below needs only Linux x86_64, an NVIDIA GPU with compute capability 7.5 (Turing) or newer and a driver that supports CUDA 13. It brings its own R and libraries, and needs no CUDA toolkit or compiler.

To build from source (the install script), you need Linux x86_64 and:

NVIDIA GPU compute capability 7.5 (Turing) or newer
CUDA Toolkit 12.2 or newer (RAPIDS 26.x is tested with CUDA 13, which the installers and pixi use)
RAPIDS libcudf 26.02 or newer (developed and tested on 26.10)
R 4.3 or newer

Volta (7.0) GPUs are not supported: that would need a source build against a CUDA 12 RAPIDS, which no install route provides.

The install script clones cuplyr, finds libcudf through pixi, conda or your system (in that order), and builds the package. The pixi environment carries libcudf and the CUDA 13 build tools (nvcc and the CUDA headers), so --method=pixi needs only a system C++ compiler; a system toolkit set through CUDA_HOME still wins. The conda method installs cuda-nvcc into its environment itself:

curl -fsSL https://raw.githubusercontent.com/bbtheo/cuplyr/main/install.sh | bash

To pick the method yourself, pass --method=pixi, --method=conda or --method=system. --dry-run shows what the script would do. From a clone, run ./install.sh with the same options.

conda and pixi

The conda package r-cuplyr is published on the bbtheo channel on anaconda.org. It is a binary built against RAPIDS libcudf 26.10 and CUDA 13, so it needs no compiler or CUDA toolkit on your machine, only an NVIDIA driver that supports CUDA 13. Install it into an active conda environment (for a new one, run conda create -n cuplyr and conda activate cuplyr first):

conda install -c bbtheo -c rapidsai -c conda-forge -c nvidia r-cuplyr

mamba takes the same arguments. If your conda configuration sets strict channel priority and the solve fails, add --no-channel-priority.

With pixi, create a project with the same channels and add the package:

pixi init -c bbtheo -c rapidsai -c conda-forge -c nvidia cuplyr-project
cd cuplyr-project
pixi add r-cuplyr

Then start R in the project with pixi run R (or pixi shell, then R).

How the package is built and published is described in conda/README.md.

Check the installation

Check the installation from R:

If something is wrong, check_deps() lists what is missing. diagnostics() prints the system details to paste into a bug report.

Learn more

Acknowledgments

cuplyr is built on RAPIDS cuDF, NVIDIA’s open-source GPU data frame library, by the RAPIDS team.