Intro
GPU-accelerated algorithms via the WGPU backend on cubecl. All you need is a GPU that WGPU can talk to: Metal on macOS, Vulkan on Linux, DX12 or Vulkan on Windows. No CUDA, no vendor lock-in, no separate GPU toolchain to install. Check with gpu_available() after installing; if that returns TRUE, everything in the package will run. If it returns FALSE, your drivers are the problem, and the cubecl book covers the set up per platform.
The package is designed to support the bixverse package. Additionally, also provides some neural net-based versions of embedding methods for manifoldsR + a GPU-accelerated version of the Adam optimiser for UMAP.
Heads up: the package is being refactored at the moment, so the R-facing API can shift between versions. lifecycle: experimental covers the whole surface and means it.
Usage
Installation
On the GPU side there is nothing extra to install beyond working drivers, whatever your OS ships is what WGPU picks up. Previously, the CPU-based versions of neural net acceleration where running through ndarray and accelerated via OpenBLAS (Linux) or Accelerate (Mac). This has been now replaced with the flex framework.
The easy route is r-universe. You get a pre-built binary, so no Rust toolchain and no compile:
install.packages(
"bixverse.gpu",
repos = c("https://gregorlueg.r-universe.dev", "https://cloud.r-project.org")
)From source
You will need Rust on your system to install the package from source. An installation guide is provided here. There is a bunch of further help written here by the rextendr guys in terms of Rust set up. (bixverse.gpu as bixverse both use rextendr to interface with Rust.)
Setting up Rust
Steps for installation:
- In the terminal, install Rust
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
- In R, install rextendr:
install.packages("rextendr")
- Finally install bixverse.gpu:
devtools::install_github("https://github.com/GregorLueg/bixverse.gpu")
Windows support
Windows works. WGPU was never the problem there, DX12 and Vulkan are both well covered, and the h5 dependency (for reading h5ad files) turned out to be a dull MAX_PATH issue rather than a cross-compile one: R CMD INSTALL builds in a deep temp directory, and the HDF5 CMake build pushed object paths past the 260 character limit. The build now puts the cargo target directory in ~/.bixverse-gpu-cargo, which stays clear of it. Same fix as in bixverse.
One thing is still missing on Windows: the FFT-accelerated tSNE. FFTW does not come along for the ride, so tsne_gpu(approx_type = "fft") errors there. Barnes-Hut (approx_type = "bh", the default) works everywhere.
How to use the package.
The package website can be found here. This package is not a stand-alone package, but designed to support the bixverse with GPU-accelerated methods. If you are however interesting in just using the GPU-accelerated kNN searches, feel free to use the respective rs_ functions for that. Or if you want to train a neural network for UMAP, the package also provides what you need.
