Learn R Programming

rslurm: submit R code to a Slurm cluster

[R build status]https://github.com/earthlab/rslurm/workflows/R-CMD-check/badge.svg)

About

Development of this R package was supported by the National Socio-Environmental Synthesis Center (SESYNC) under funding received from the National Science Foundation grants DBI-1052875 and DBI-1639145.

The package was developed by Philippe Marchand and Ian Carroll, with Mike Smorul and Rachael Blake contributing. Erick Verleye is the current maintainer.

As of January 2023 the University of Colorado Boulder’s Earth Lab adopted rslurm and is responsible for all future maintenance.

Installation

You can install the released version of rslurm from CRAN with:

install.packages("rslurm")

And the development version from GitHub with:

# install.packages("devtools")
devtools::install_github("earthlab/rslurm")

Documentation

Package documentation is accessible from the R console through package?rslurm and online.

Example

Note that job submission is only possible on a system with access to a Slurm workload manager (i.e. a system where the command line utilities squeue or sinfo return information from a Slurm head node).

To illustrate a typical rslurm workflow, we use a simple function that takes a mean and standard deviation as parameters, generates a million normal deviates and returns the sample mean and standard deviation.

test_func <- function(par_mu, par_sd) {
    samp <- rnorm(10^6, par_mu, par_sd)
    c(s_mu = mean(samp), s_sd = sd(samp))
}

We then create a parameter data frame where each row is a parameter set and each column matches an argument of the function.

pars <- data.frame(par_mu = 1:10,
                   par_sd = seq(0.1, 1, length.out = 10))

We can now pass that function and the parameters data frame to slurm_apply, specifying the number of cluster nodes to use and the number of CPUs per node.

library(rslurm)
sjob <- slurm_apply(test_func, pars, jobname = 'test_apply',
                    nodes = 2, cpus_per_node = 2, submit = FALSE)

The output of slurm_apply is a slurm_job object that stores a few pieces of information (job name, job ID, and the number of nodes) needed to retrieve the job’s output.

See Get started for more information.

Copy Link

Version

Install

install.packages('rslurm')

Monthly Downloads

485

Version

0.6.2

License

GPL-3

Maintainer

Erick Verleye

Last Published

February 24th, 2023

Functions in rslurm (0.6.2)

slurm_job

Create a slurm_job object
slurm_map

Parallel execution of a function over a list on the Slurm cluster
print_job_status

Deprecated functions in package rslurm.
local_slurm_array

Execute a Slurm job locally
rslurm-package

Introduction to the rslurm Package
get_job_status

Get the status of a Slurm job
slurm_call

Execution of a single function call on the Slurm cluster
slurm_apply

Parallel execution of a function on the Slurm cluster
cleanup_files

Deletes temporary files associated with a Slurm job
get_slurm_out

Reads the output of a function calculated on the Slurm cluster
cancel_slurm

Cancels a scheduled Slurm job
print_job_status-deprecated

Prints the status of a Slurm job and, if completed, its console/error output