From 2fe2e0571bbfeb5e9f993205808a1b034e9794ac Mon Sep 17 00:00:00 2001 From: Tony Kew Date: Thu, 23 Oct 2025 17:18:26 -0400 Subject: [PATCH 1/8] Initial commit of R Rocker Project container files Tony --- .../R-Rocker_Project/R_rocker_4.5.1.def | 232 ++++++++++++++++++ .../R-Rocker_Project/estimate_pi.R | 30 +++ .../R-Rocker_Project/slurm_ARM64_example.bash | 34 +++ .../R-Rocker_Project/slurm_example.bash | 35 +++ 4 files changed, 331 insertions(+) create mode 100644 containers/2_ApplicationSpecific/R-Rocker_Project/R_rocker_4.5.1.def create mode 100644 containers/2_ApplicationSpecific/R-Rocker_Project/estimate_pi.R create mode 100755 containers/2_ApplicationSpecific/R-Rocker_Project/slurm_ARM64_example.bash create mode 100755 containers/2_ApplicationSpecific/R-Rocker_Project/slurm_example.bash diff --git a/containers/2_ApplicationSpecific/R-Rocker_Project/R_rocker_4.5.1.def b/containers/2_ApplicationSpecific/R-Rocker_Project/R_rocker_4.5.1.def new file mode 100644 index 00000000..8df8784e --- /dev/null +++ b/containers/2_ApplicationSpecific/R-Rocker_Project/R_rocker_4.5.1.def @@ -0,0 +1,232 @@ +Bootstrap: docker +From: ghcr.io/rocker-org/r-ver:4.5.1 + +%post -c /bin/bash + # Set the timezone, if unset + test -h /etc/localtime || ln -fs /usr/share/zoneinfo/America/New_York /etc/localtime + + cp /etc/apt/sources.list /etc/apt/sources.list~ + sed -E -i 's/^# deb-src /deb-src /' /etc/apt/sources.list + apt-get -y update + + # Install man & man pages - this section can be removed if not needed + # NOTE: Do this before installing anything else so their man pages are installed + sed -e '\|/usr/share/man|s|^#*|#|g' -i /etc/dpkg/dpkg.cfg.d/excludes + DEBIAN_FRONTEND=noninteractive apt-get -y install apt-utils groff dialog man-db manpages manpages-posix manpages-dev + rm -f /usr/bin/man + dpkg-divert --quiet --remove --rename /usr/bin/man + + # O/S package updates: + DEBIAN_FRONTEND=noninteractive apt-get -y upgrade + + DEBIAN_FRONTEND=noninteractive apt-get -y install \ + bash-completion \ + ca-certificates \ + tzdata \ + locales \ + zip \ + unzip \ + wget \ + git \ + libgit2-dev \ + subversion \ + gawk \ + file \ + gnupg2 \ + gpg \ + gpg-agent \ + libssh2-1-dev \ + libsasl2-dev \ + build-essential \ + autoconf \ + automake \ + pkg-config \ + cmake \ + cmake-data \ + cmake-extras \ + cmake-format \ + libclang-dev \ + python3 \ + python3-pip \ + python3-setuptools \ + python3-sphinx \ + python3-sphinx-rtd-theme \ + python3-dev \ + python-is-python3 \ + libpython3-dev \ + devscripts \ + perl \ + zstd \ + gnulib \ + libicu-dev \ + libssl-dev \ + zlib1g-dev \ + libzstd-dev \ + libbz2-dev \ + lbzip2 \ + xz-utils \ + libncurses5-dev \ + libncursesw5-dev \ + libreadline-dev \ + liblzma-dev \ + liblz4-tool \ + libcurl4-gnutls-dev \ + libdeflate-dev \ + libx11-dev \ + x11proto-core-dev \ + xfonts-base \ + xvfb \ + xauth \ + xtail \ + xzdec \ + libxt-dev \ + libxt6 \ + libxtst6 \ + xorg-dev \ + fonts-roboto \ + fonts-texgyre \ + gsfonts \ + ghostscript \ + libpng-dev \ + libtiff5-dev \ + libfreetype6-dev \ + libjpeg-dev \ + libjpeg-turbo8-dev \ + libjq-dev \ + liblzma-dev \ + texinfo \ + texlive \ + texlive-base \ + texlive-fonts-recommended \ + texlive-fonts-extra \ + texlive-font-utils \ + texlive-lang-all \ + texlive-extra-utils \ + texlive-latex-recommended \ + texlive-latex-extra \ + libpcre2-posix3 \ + libpcre2-dev \ + openjdk-21-jdk-headless \ + nvidia-cuda-dev \ + nvidia-cuda-toolkit \ + libxml2-dev \ + libudunits2-dev \ + libgdal-dev \ + libharfbuzz-dev \ + libfribidi-dev \ + libmagick++-dev \ + libgsl-dev \ + libfftw3-dev \ + libcairo2-dev \ + libpango1.0-dev \ + libgmp-dev \ + tk-dev \ + tcl-dev \ + libmpfr-dev \ + libnetcdf-dev \ + libhdf4-alt-dev \ + libhdf5-dev \ + libhts3 \ + libhts-dev \ + libhtscodecs2 \ + libhtscodecs-dev \ + libopenblas64-0 \ + libopenblas64-dev \ + liblapack3 \ + liblapack-dev \ + liblapacke-dev \ + libscalapack-openmpi-dev \ + openmpi-bin \ + openmpi-common \ + libopenmpi-dev \ + libpmix2t64 \ + libpmix-dev \ + libgl1-mesa-dev \ + libglpk-dev \ + libglu1-mesa-dev \ + libgmp3-dev \ + libgsl0-dev \ + gdebi-core \ + libgeos-dev \ + libhunspell-dev \ + libpq-dev \ + libproj-dev \ + libprotobuf-dev \ + protobuf-compiler \ + libsqlite3-dev \ + unixodbc-dev \ + sqlite3 \ + libv8-dev \ + libzmq3-dev \ + postgis \ + psmisc \ + hugo \ + swig \ + curl \ + jq \ + nano \ + vim \ + less \ + apt-file + + # NOTE: apt-file is generally not needed to run, but can be useful during development + apt-file update + + # These steps are necessary to configure Perl and can cause issues with Python if omitted + sed -i -e 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen + dpkg-reconfigure --frontend=noninteractive locales + update-locale LANG=en_US.UTF-8 + + # Libraries in /usr/local/lib + # Include files in /usr/local/include + export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/local/lib" + export CFLAGS="${CFLAGS} -I/usr/local/include" + export CPPFLAGS="${CPPFLAGS} -I/usr/local/include" + export CXXFLAGS="${CXXFLAGS} -I/usr/local/include" + export FFLAGS="${FFLAGS} -I/usr/local/include" + export LDFLAGS="${LDFLAGS} -L/usr/local/lib -Xlinker -rpath -Xlinker \"/usr/local/lib\"" + export CMAKE_BUILD_PARALLEL_LEVEL="$(nproc)" + pip_install_dir="$(python3 -c 'import sys; print("/usr/local/lib/python" + str(sys.version_info.major) + "." + str(sys.version_info.minor) + "/dist-packages")')" + export PYTHONPATH="${pip_install_dir}:${PYTHONPATH}" + export PATH="${PATH}:${pip_install_dir}/bin" + + # distro from the Ubuntu package clashes with the one from pip + DEBIAN_FRONTEND=noninteractive apt-get -y remove python3-distro + pip install --prefix="/usr" distro setuptools + + # make sure TMPDIR is on a local filesystem + export TMPDIR="${SLURMTMPDIR:-/var/tmp}" + # container setting required from some builds: + export container="oci" + # CUDA installed with Ubuntu packages, so set CUDA_HOME to /usr + export CUDA_HOME="/usr" + + R --version + +### # Sample code to add R packages from CRAN inside this container +### for package in \ +### Rcpp \ +### RcppEigen +### do +### R -e "install.packages(pkgs = \"${package}\", repos = \"https://cran.r-project.org\", +### lib = \"/usr/local/lib/R/library\", type = \"source\", dependencies = TRUE)" +### done + +%environment + # make sure TMPDIR is on a local filesystem + export TMPDIR="${SLURMTMPDIR:-/var/tmp}" + # container setting required from some builds: + export container="oci" + # CUDA installed with Ubuntu packages, so set CUDA_HOME to /usr + export CUDA_HOME="/usr" + export LANG=en_US.UTF-8 + export LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:/usr/local/lib" + export PYTHONPATH="$(python3 -c 'import sys; print("/usr/local/lib/python" + str(sys.version_info.major) + "." + str(sys.version_info.minor) + "/dist-packages")'):${PYTHONPATH}" + export PATH="$(python3 -c 'import sys; print("/usr/local/lib/python" + str(sys.version_info.major) + "." + str(sys.version_info.minor) + "/dist-packages/bin")'):${PATH}" + +%runscript + #!/bin/bash + export PS1="rocker-R> " + # Exec passed command (required for Modal ENTRYPOINT compatibility) + exec "$@" + diff --git a/containers/2_ApplicationSpecific/R-Rocker_Project/estimate_pi.R b/containers/2_ApplicationSpecific/R-Rocker_Project/estimate_pi.R new file mode 100644 index 00000000..78636356 --- /dev/null +++ b/containers/2_ApplicationSpecific/R-Rocker_Project/estimate_pi.R @@ -0,0 +1,30 @@ +# +# Estimating Pi Using Monte Carlo Simulation in R +# by Andrea Gustafsen +# +# https://rpubs.com/andrea_gustafsen/839901 +# +estimate_pi <- function(seed = 28, iterations = 1000){ + # set seed for reproducibility + set.seed(seed) + + # generate the (x, y) points + x <- runif(n = iterations, min = 0, max = 1) + y <- runif(n = iterations, min = 0, max = 1) + + # calculate + sum_sq_xy <- sqrt(x^2 + y^2) + + # see how many points are within circle + index_within_circle <- which(sum_sq_xy <= 1) + points_within_circle = length(index_within_circle) + + # estimate pi + pi_est <- 4 * points_within_circle / iterations + return(pi_est) +} +no_of_iterations <- c(10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000) +res <- sapply(no_of_iterations, function(n)estimate_pi(iterations = n)) +names(res) <- no_of_iterations +res + diff --git a/containers/2_ApplicationSpecific/R-Rocker_Project/slurm_ARM64_example.bash b/containers/2_ApplicationSpecific/R-Rocker_Project/slurm_ARM64_example.bash new file mode 100755 index 00000000..597a51e5 --- /dev/null +++ b/containers/2_ApplicationSpecific/R-Rocker_Project/slurm_ARM64_example.bash @@ -0,0 +1,34 @@ +#!/bin/bash -l + +## This file is intended to serve as a template to be downloaded and modified for your use case. +## For more information, refer to the following resources whenever referenced in the script- +## README- https://github.com/ubccr/ccr-examples/tree/main/slurm/README.md +## DOCUMENTATION- https://docs.ccr.buffalo.edu/en/latest/hpc/jobs + +#SBATCH --cluster="ub-hpc" +#SBATCH --partition="arm64" +#SBATCH --qos="arm64" + +## Select an account that has access to the arm64 partition (see `slimits | grep arm64`) +#SBATCH --account="[SlurmAccountName]" + +## Job runtime limit, the job will be canceled once this limit is reached. Format- dd-hh:mm:ss +#SBATCH --time=00:20:00 + +## NOTE: R uses only one core, unless you specifically use functions that take +## advantage of multiple cores, such as the 'parallel' package. +## This example allocates 6 cores, so apptainer has a thread for itself, +## plus a thread for each bind mount, leaving one core for the R process +#SBATCH --nodes=1 +#SBATCH --ntasks-per-node=1 +#SBATCH --cpus-per-task=6 +#SBATCH --mem=36GB + +R_version="4.5.1" + +# Run containerized R +apptainer run \ + -B /projects:/projects,/scratch:/scratch,/util:/util,/vscratch:/vscratch \ + R_rocker_${R_version}-$(arch).sif \ + Rscript estimate_pi.R + diff --git a/containers/2_ApplicationSpecific/R-Rocker_Project/slurm_example.bash b/containers/2_ApplicationSpecific/R-Rocker_Project/slurm_example.bash new file mode 100755 index 00000000..3ee0a945 --- /dev/null +++ b/containers/2_ApplicationSpecific/R-Rocker_Project/slurm_example.bash @@ -0,0 +1,35 @@ +#!/bin/bash -l + +## This file is intended to serve as a template to be downloaded and modified for your use case. +## For more information, refer to the following resources whenever referenced in the script- +## README- https://github.com/ubccr/ccr-examples/tree/main/slurm/README.md +## DOCUMENTATION- https://docs.ccr.buffalo.edu/en/latest/hpc/jobs + +## Select a cluster, partition, qos and account that is appropriate for your use case +## Available options and more details are provided in CCR's documentation: +## https://docs.ccr.buffalo.edu/en/latest/hpc/jobs/#slurm-directives-partitions-qos +#SBATCH --cluster="[cluster]" +#SBATCH --partition="[partition]" +#SBATCH --qos="[qos]" +#SBATCH --account="[SlurmAccountName]" + +## Job runtime limit, the job will be canceled once this limit is reached. Format- dd-hh:mm:ss +#SBATCH --time=00:20:00 + +## NOTE: R uses only one core, unless you specifically use functions that take +## advantage of multiple cores, such as the 'parallel' package. +## This example allocates 6 cores, so apptainer has a thread for itself, +## plus a thread for each bind mount, leaving one core for the R process +#SBATCH --nodes=1 +#SBATCH --ntasks-per-node=1 +#SBATCH --cpus-per-task=6 +#SBATCH --mem=36GB + +R_version="4.5.1" + +# Run containerized R +apptainer run \ + -B /projects:/projects,/scratch:/scratch,/util:/util,/vscratch:/vscratch \ + R_rocker_${R_version}-$(arch).sif \ + Rscript estimate_pi.R + From bc4b384d6e41f6bf1cca58395ba8fb5606626772 Mon Sep 17 00:00:00 2001 From: Tony Kew Date: Thu, 23 Oct 2025 17:34:36 -0400 Subject: [PATCH 2/8] Added new documentation files Tony --- .../R-Rocker_Project/BUILD-ARM64.md | 243 ++++++++++++++++ .../R-Rocker_Project/EXAMPLE.md | 102 +++++++ .../R-Rocker_Project/README.md | 266 ++++++++++++++++++ .../R-Rocker_Project/SLURM_ARM64_EXAMPLE.md | 84 ++++++ .../R-Rocker_Project/SLURM_EXAMPLE.md | 75 +++++ 5 files changed, 770 insertions(+) create mode 100644 containers/2_ApplicationSpecific/R-Rocker_Project/BUILD-ARM64.md create mode 100644 containers/2_ApplicationSpecific/R-Rocker_Project/EXAMPLE.md create mode 100644 containers/2_ApplicationSpecific/R-Rocker_Project/README.md create mode 100644 containers/2_ApplicationSpecific/R-Rocker_Project/SLURM_ARM64_EXAMPLE.md create mode 100644 containers/2_ApplicationSpecific/R-Rocker_Project/SLURM_EXAMPLE.md diff --git a/containers/2_ApplicationSpecific/R-Rocker_Project/BUILD-ARM64.md b/containers/2_ApplicationSpecific/R-Rocker_Project/BUILD-ARM64.md new file mode 100644 index 00000000..acf1f279 --- /dev/null +++ b/containers/2_ApplicationSpecific/R-Rocker_Project/BUILD-ARM64.md @@ -0,0 +1,243 @@ +# Build the R_rocker container on ARM64 + + +## Building the container + +1. Start an interactive job on an ARM64 node + +``` +tmp_file="$(mktemp)" +salloc --partition=arm64 --qos=arm64 --constraint=ARM64 --no-shell \ + --exclusive --time=1:00:00 2>&1 | tee "${tmp_file}" +SLURM_JOB_ID="$(head -1 "${tmp_file}" | awk '{print $NF}')" +rm "${tmp_file}" +srun --jobid="${SLURM_JOB_ID}" --export=HOME,TERM,SHELL --pty /bin/bash --login +``` + +sample outout: + +> ``` +> salloc: Pending job allocation 22171515 +> salloc: job 22171515 queued and waiting for resources +> salloc: job 22171515 has been allocated resources +> salloc: Granted job allocation 22171515 +> salloc: Nodes cpn-f06-38 are ready for job +> CCRusername@cpn-f06-38:~$ +> ``` + +2. Navigate to your build directory and use the Slurm job local temporary directory for cache + + +Change to your R directory + +``` +cd /projects/academic/[YourGroupName]/R +``` + +Then set the apptainer cache dir: + +``` +export APPTAINER_CACHEDIR=${SLURMTMPDIR} +``` + +The `R_rocker_4.5.1.def` file will already be in the directory if you have already built +on the x86_64 platform, if not, download the .def file: + +``` +test -f R_rocker_4.5.1.def || curl -o R_rocker_4.5.1.def https://raw.githubusercontent.com/tonykew/ccr-examples/refs/heads/R-Rocker_Project/containers/2_ApplicationSpecific/R-Rocker_Project/R_rocker_4.5.1.def +``` + +sample output: + +> ``` +> % Total % Received % Xferd Average Speed Time Time Time Current +> Dload Upload Total Spent Left Speed +> 100 6126 100 6126 0 0 103k 0 --:--:-- --:--:-- --:--:-- 104k +> ``` + + +3. Build your container + +Building the R container takes about ten minutes + +``` +apptainer build --fakeroot R_rocker_4.5.1-$(arch).sif R_rocker_4.5.1.def +``` + +sample truncated output: + +> ``` +> [....] +> INFO: Adding environment to container +> INFO: Creating SIF file... +> INFO: Build complete: R_rocker_4.5.1-aarch64.sif +> ``` + +Quick test of the new container .sif image + +``` +apptainer run \ + -B /projects:/projects,/scratch:/scratch,/util:/util,/vscratch:/vscratch \ + R_rocker_4.5.1-$(arch).sif \ + R --version +```` + +Sample output: + +> ``` +> R version 4.5.1 (2025-06-13) -- "Great Square Root" +> Copyright (C) 2025 The R Foundation for Statistical Computing +> Platform: x86_64-pc-linux-gnu +> +> R is free software and comes with ABSOLUTELY NO WARRANTY. +> You are welcome to redistribute it under the terms of the +> GNU General Public License versions 2 or 3. +> For more information about these matters see +> https://www.gnu.org/licenses/. +> +> ``` + +Exit the Slurm interactive session + +``` +exit +``` + +sample output: + +> ``` +> CCRusername@login1$ +> ``` + +End the Slurm job + +``` +scancel "${SLURM_JOB_ID}" +unset SLURM_JOB_ID +``` + +4. Running the container + +Start an interactive job on an ARM64 node +Notes: + R uses only one core, unless you specifically use functions that take + advantage of multiple cores, such as the 'parallel' package. This example + allocates 6 cores, so apptainer has a thread for itself, plus a thread for + each bind mount, leaving one core for the R process. Request more cores if + you are running parallel code. + + If you use R packages that uses CUDA, add the Slurm directive to request + GPU(s) e.g. "--gpus-per-node=1" and add tht "--nv" opion to apptainer so the + requested GPU(s) are available inside the container. + +``` +tmp_file="$(mktemp)" +salloc --partition=arm64 --qos=arm64 --constraint=ARM64 --no-shell \ + --nodes=1 --ntasks-per-node=1 --cpus-per-task=6 --mem=32GB \ + --time=1:00:00 2>&1 | tee "${tmp_file}" +SLURM_JOB_ID="$(head -1 "${tmp_file}" | awk '{print $NF}')" +rm "${tmp_file}" +srun --jobid="${SLURM_JOB_ID}" --export=HOME,TERM,SHELL --pty /bin/bash --login +``` + +sample outout: + +> ``` +> salloc: Pending job allocation 22171524 +> salloc: job 22171524 queued and waiting for resources +> salloc: job 22171524 has been allocated resources +> salloc: Granted job allocation 22171524 +> salloc: Nodes cpn-f06-38 are ready for job +> CCRusername@cpn-f06-38:~$ +> ``` + +Change to your R directory + +``` +cd /projects/academic/[YourGroupName]/R +``` + +Start the R container instance + +``` +apptainer shell \ + -B /projects:/projects,/scratch:/scratch,/util:/util,/vscratch:/vscratch \ + ./R_rocker_4.5.1-$(arch).sif +``` + +All the following commands are run from the "Apptainer> " prompt +run R + +``` +R +``` + +Sampleoutput: + +> ``` +> +> R version 4.5.1 (2025-06-13) -- "Great Square Root" +> Copyright (C) 2025 The R Foundation for Statistical Computing +> Platform: x86_64-pc-linux-gnu +> +> R is free software and comes with ABSOLUTELY NO WARRANTY. +> You are welcome to redistribute it under certain conditions. +> Type 'license()' or 'licence()' for distribution details. +> +> Natural language support but running in an English locale +> +> R is a collaborative project with many contributors. +> Type 'contributors()' for more information and +> 'citation()' on how to cite R or R packages in publications. +> +> Type 'demo()' for some demos, 'help()' for on-line help, or +> 'help.start()' for an HTML browser interface to help. +> Type 'q()' to quit R. +> +> > +> ``` + +exit R from the ">" prompt with: + +``` +q() +``` + +Expected output + +> ``` +> Apptainer> +> ``` + +Exit the Apptainer container instance +From the "Apptainer>" prompt: + +``` +exit +``` + +sample output: +> ``` +> CCRusername@cpn-d01-39~$ +> ``` + +Exit the Slurm interactive session + +``` +exit +``` + +sample output: + +> ``` +> logout +> CCRusername@login1$ +> ``` + +End the Slurm job + +``` +scancel "${SLURM_JOB_ID}" +unset SLURM_JOB_ID +``` + diff --git a/containers/2_ApplicationSpecific/R-Rocker_Project/EXAMPLE.md b/containers/2_ApplicationSpecific/R-Rocker_Project/EXAMPLE.md new file mode 100644 index 00000000..aa2db49a --- /dev/null +++ b/containers/2_ApplicationSpecific/R-Rocker_Project/EXAMPLE.md @@ -0,0 +1,102 @@ +# R_rocker Example + +Start an interactive job in the "debug" partition + +``` +tmp_file="$(mktemp)" +salloc --cluster=ub-hpc --partition=debug --qos=debug --no-shell \ + --nodes=1 --cpus-per-task=1 --tasks-per-node=6 --mem=36GB \ + --account="[SlurmAccountName]" --time=1:00:00 2>&1 | tee "${tmp_file}" +SLURM_JOB_ID="$(head -1 "${tmp_file}" | awk '{print $NF}')" +rm "${tmp_file}" +srun --jobid="${SLURM_JOB_ID}" --export=HOME,TERM,SHELL --pty /bin/bash --login +``` + +sample outout: + +> ``` +> salloc: Pending job allocation 22172066 +> salloc: job 22172066 queued and waiting for resources +> salloc: job 22172066 has been allocated resources +> salloc: Granted job allocation 22172066 +> salloc: Nodes cpn-d01-39 are ready for job +> CCRusername@cpn-d01-39~$ +> ``` + +Change to your R directory + +``` +cd /projects/academic/[YourGroupName]/R +``` + +Start the R container instance + +``` +apptainer shell \ + -B /projects:/projects,/scratch:/scratch,/util:/util,/vscratch:/vscratch \ + ./R_rocker_4.5.1-$(arch).sif +``` + +Download the exmaple R script [estimate_pi.R](https://raw.githubusercontent.com/tonykew/ccr-examples/refs/heads/R-Rocker_Project/containers/2_ApplicationSpecific/R-Rocker_Project/estimate_pi.R) +This code is writen by Andrea Gustafsen - see: +https://rpubs.com/andrea_gustafsen/839901 + +``` +test -f estimate_pi.R || curl -o estimate_pi.R https://raw.githubusercontent.com/tonykew/ccr-examples/refs/heads/R-Rocker_Project/containers/2_ApplicationSpecific/R-Rocker_Project/estimate_pi.R +``` + +sample output: + +> ``` +> % Total % Received % Xferd Average Speed Time Time Time Current +> Dload Upload Total Spent Left Speed +> 100 874 100 874 0 0 7536 0 --:--:-- --:--:-- --:--:-- 7600 +> ``` + +Run the R script +Note: This script takes about 2 minutes to run, during which there is no output + +``` +Rscript estimate_pi.R +``` + +Sample output: + +> ``` +> 10 100 1000 10000 1e+05 1e+06 1e+07 1e+08 +> 2.400000 3.160000 3.184000 3.158400 3.138760 3.143816 3.141868 3.141650 +> 1e+09 +> 3.141679 +> ``` + +Exit the Apptainer container instance +From the "Apptainer>" prompt: + +``` +exit +``` + +sample output: +> ``` +> CCRusername@cpn-d01-39~$ +> ``` + +Exit the Slurm interactive session + +``` +exit +``` + +sample output: + +> ``` +> CCRusername@login1$ +> ``` + +End the Slurm job + +``` +scancel "${SLURM_JOB_ID}" +unset SLURM_JOB_ID +``` + diff --git a/containers/2_ApplicationSpecific/R-Rocker_Project/README.md b/containers/2_ApplicationSpecific/R-Rocker_Project/README.md new file mode 100644 index 00000000..ea8131de --- /dev/null +++ b/containers/2_ApplicationSpecific/R-Rocker_Project/README.md @@ -0,0 +1,266 @@ +# Example R container, based on the Rocker Project "r-ver" image + +The [Rocker Project](https://rocker-project.org) provides a number of [GPL 2 or later](https://opensource.org/license/gpl-2-0) licenced ["R" containers](https://rocker-project.org/images/) +This example is based on the [r-ver](https://rocker-project.org/images/versioned/r-ver.html) image which is, in turn, based on the [r-base](https://hub.docker.com/_/r-base) +offical R image +The [r-ver](https://rocker-project.org/images/versioned/r-ver.html) image uses Ubuntu LTS rather than Debian, with an emphasis on +reproducibility. + + +## Building the container + +A brief guide to building the R_rocker container follows:
+Please refer to CCR's [container documentation](https://docs.ccr.buffalo.edu/en/latest/howto/containerization/) for more detailed information on building and using Apptainer. + +NOTE: for building on the ARM64 platform see [BUILD-ARM64.md](./BUILD-ARM64.md) + +1. Start an interactive job + +Apptainer is not available on the CCR login nodes and the compile nodes may not provide enough resources for you to build a container. We recommend requesting an interactive job on a compute node to conduct this build process.
+See CCR docs for more info on [running jobs](https://docs.ccr.buffalo.edu/en/latest/hpc/jobs/#interactive-job-submission) + +``` +tmp_file="$(mktemp)" +salloc --cluster=ub-hpc --partition=debug --qos=debug --no-shell --exclusive \ + --account="[SlurmAccountName]" --mem=0 --time=1:00:00 2>&1 | tee "${tmp_file}" +SLURM_JOB_ID="$(head -1 "${tmp_file}" | awk '{print $NF}')" +rm "${tmp_file}" +srun --jobid="${SLURM_JOB_ID}" --export=HOME,TERM,SHELL --pty /bin/bash --login +``` + +sample outout: + +> ``` +> salloc: Pending job allocation 22171515 +> salloc: job 22171515 queued and waiting for resources +> salloc: job 22171515 has been allocated resources +> salloc: Granted job allocation 22171515 +> salloc: Nodes cpn-d01-39 are ready for job +> CCRusername@pn-d01-39:~$ +> ``` + +2. Navigate to your build directory and use the Slurm job local temporary directory for cache + +You should now be on the compute node allocated to you. +In this example we're using our project directory for our build directory. + +Change to your R directory + +``` +cd /projects/academic/[YourGroupName]/R +``` + +Then set the apptainer cache dir: + +``` +export APPTAINER_CACHEDIR=${SLURMTMPDIR} +``` + +Download the .def file + +``` +test -f R_rocker_4.5.1.def || curl -o R_rocker_4.5.1.def https://raw.githubusercontent.com/tonykew/ccr-examples/refs/heads/R-Rocker_Project/containers/2_ApplicationSpecific/R-Rocker_Project/R_rocker_4.5.1.def +``` + +sample output: + +> ``` +> % Total % Received % Xferd Average Speed Time Time Time Current +> Dload Upload Total Spent Left Speed +> 100 6126 100 6126 0 0 97501 0 --:--:-- --:--:-- --:--:-- 98806 +> ``` + +3. Build your container + +Building the R container takes about ten minutes + +``` +apptainer build --fakeroot R_rocker_4.5.1-$(arch).sif R_rocker_4.5.1.def +``` + +sample truncated output: + +> ``` +> [....] +> INFO: Adding environment to container +> INFO: Creating SIF file... +> INFO: Build complete: R_rocker_4.5.1-x86_64.sif +> ``` + +Quick test of the new container .sif image + +``` +apptainer run \ + -B /projects:/projects,/scratch:/scratch,/util:/util,/vscratch:/vscratch \ + R_rocker_4.5.1-$(arch).sif \ + R --version +```` + +Sample output: + +> ``` +> R version 4.5.1 (2025-06-13) -- "Great Square Root" +> Copyright (C) 2025 The R Foundation for Statistical Computing +> Platform: x86_64-pc-linux-gnu +> +> R is free software and comes with ABSOLUTELY NO WARRANTY. +> You are welcome to redistribute it under the terms of the +> GNU General Public License versions 2 or 3. +> For more information about these matters see +> https://www.gnu.org/licenses/. +> +> ``` + +Exit the Slurm interactive session + +``` +exit +``` + +sample output: + +> ``` +> CCRusername@login1$ +> ``` + +End the Slurm job + +``` +scancel "${SLURM_JOB_ID}" +unset SLURM_JOB_ID +``` + +4. Running the container + +Start an interactive job e.g. + +``` +tmp_file="$(mktemp)" +salloc --cluster=ub-hpc --partition=general-compute --qos=general-compute \ + --no-shell --mem=128GB --nodes=1 --cpus-per-task=1 --tasks-per-node=12 \ + --account="[SlurmAccountName]" --time=5:00:00 2>&1 | tee "${tmp_file}" +SLURM_JOB_ID="$(head -1 "${tmp_file}" | awk '{print $NF}')" +rm "${tmp_file}" +srun --jobid="${SLURM_JOB_ID}" --export=HOME,TERM,SHELL --pty /bin/bash --login +``` + +sample outout: + +> ``` +> salloc: Pending job allocation 22171524 +> salloc: job 22171524 queued and waiting for resources +> salloc: job 22171524 has been allocated resources +> salloc: Granted job allocation 22171524 +> salloc: Nodes cpn-d01-19 are ready for job +> ``` + +Change to your R directory + +``` +cd /projects/academic/[YourGroupName]/R +``` + +Start the R container instance + +``` +apptainer shell \ + -B /projects:/projects,/scratch:/scratch,/util:/util,/vscratch:/vscratch \ + ./R_rocker_4.5.1-$(arch).sif +``` + +All the following commands are run from the "Apptainer> " prompt +run R + +``` +R +``` + +Sampleoutput: + +> ``` +> +> R version 4.5.1 (2025-06-13) -- "Great Square Root" +> Copyright (C) 2025 The R Foundation for Statistical Computing +> Platform: x86_64-pc-linux-gnu +> +> R is free software and comes with ABSOLUTELY NO WARRANTY. +> You are welcome to redistribute it under certain conditions. +> Type 'license()' or 'licence()' for distribution details. +> +> Natural language support but running in an English locale +> +> R is a collaborative project with many contributors. +> Type 'contributors()' for more information and +> 'citation()' on how to cite R or R packages in publications. +> +> Type 'demo()' for some demos, 'help()' for on-line help, or +> 'help.start()' for an HTML browser interface to help. +> Type 'q()' to quit R. +> +> > +> ``` + +exit R from the ">" prompt with: + +``` +q() +``` + +Expected output + +> ``` +> Apptainer> +> ``` + +Exit the Apptainer container instance +From the "Apptainer>" prompt: + +``` +exit +``` + +sample output: +> ``` +> CCRusername@cpn-d01-39~$ +> ``` + +Exit the Slurm interactive session + +``` +exit +``` + +sample output: + +> ``` +> logout +> CCRusername@login1$ +> ``` + +End the Slurm job + +``` +scancel "${SLURM_JOB_ID}" +unset SLURM_JOB_ID +``` + + +See the [EXAMPLES file](./EXAMPLES.md) for more info. + +## Sample Slurm scripts + +Slurm script examples: + +### x86_64 example +[R example](https://raw.githubusercontent.com/tonykew/ccr-examples/refs/heads/R-Rocker_Project/containers/2_ApplicationSpecific/R-Rocker_Project/slurm_example.bash) + +### ARM64 example +[R ARM64 example](https://raw.githubusercontent.com/ubccr/ccr-examples/refs/heads/R-Rocker_Project/containers/2_ApplicationSpecific/R-Rocker_Project/slurm_ARM64_example.bash) + + +## Documentation Resources + +For more information on R see the [R project website](https://www.r-project.org), the [R Documentation](https://www.r-project.org/other-docs.html), +the [Rocker Project website](https://rocker-project.org), the [Rocker Project Images](https://rocker-project.org/images), +and the [Rocker Project Versioned 2 github repo](https://github.com/rocker-org/rocker-versioned2) + diff --git a/containers/2_ApplicationSpecific/R-Rocker_Project/SLURM_ARM64_EXAMPLE.md b/containers/2_ApplicationSpecific/R-Rocker_Project/SLURM_ARM64_EXAMPLE.md new file mode 100644 index 00000000..e4079a20 --- /dev/null +++ b/containers/2_ApplicationSpecific/R-Rocker_Project/SLURM_ARM64_EXAMPLE.md @@ -0,0 +1,84 @@ +# R_rocker ARM64 Slurm example + +Change to your R directory + +``` +cd /projects/academic/[YourGroupName]/R +``` + +Download the slurm sample scrip and the exmaple R script [estimate_pi.R](https://raw.githubusercontent.com/tonykew/ccr-examples/refs/heads/R-Rocker_Project/containers/2_ApplicationSpecific/R-Rocker_Project/estimate_pi.R) +The example code is writen by Andrea Gustafsen - see: +https://rpubs.com/andrea_gustafsen/839901 + +``` +test -f estimate_pi.R || curl -o estimate_pi.R https://raw.githubusercontent.com/tonykew/ccr-examples/refs/heads/R-Rocker_Project/containers/2_ApplicationSpecific/R-Rocker_Project/estimate_pi.R +test -f slurm_ARM64_example.bash || curl -o slurm_ARM64_example.bash https://raw.githubusercontent.com/tonykew/ccr-examples/refs/heads/R-Rocker_Project/containers/2_ApplicationSpecific/R-Rocker_Project/slurm_ARM64_example.bash +``` + +sample output: + +> ``` +> % Total % Received % Xferd Average Speed Time Time Time Current +> Dload Upload Total Spent Left Speed +> 100 874 100 874 0 0 14616 0 --:--:-- --:--:-- --:--:-- 14813 +> % Total % Received % Xferd Average Speed Time Time Time Current +> Dload Upload Total Spent Left Speed +> 100 1268 100 1268 0 0 9810 0 --:--:-- --:--:-- --:--:-- 9829 +> ``` + +Modify the Slurm script - change the account to one that has access to the +"arm64" partition (see `slimits | grep arm64`) + +For example: + +``` +slimits | grep arm64 +``` + +sample output: + +> ``` +> ub-hpc ccradmintest tkewtest arm64,class,debug,eai-test,general-compute,industry,scavenger,viz +> ``` + +So my test account has access to the "arm64" partition using the account +"ccradmintest" + +``` +cat slurm_ARM64_example.bash +``` + +abridged sample output: + +> ``` +> [...] +#SBATCH --account="ccradmintest" +> [...] +> ``` + +Submit the Slurm script + +``` +sbatch ./slurm_ARM64_example.bash +``` + +sample output: + +> ``` +> Submitted batch job 22173297 on cluster ub-hpc +> ``` + +The Slurm output file in this case is slurm-22173297.out +Once this Slurm job completed: + +``` +cat slurm-22173297.out +``` + +> ``` +> 10 100 1000 10000 1e+05 1e+06 1e+07 1e+08 +> 2.400000 3.160000 3.184000 3.158400 3.138760 3.143816 3.141868 3.141650 +> 1e+09 +> 3.141679 +> ``` + diff --git a/containers/2_ApplicationSpecific/R-Rocker_Project/SLURM_EXAMPLE.md b/containers/2_ApplicationSpecific/R-Rocker_Project/SLURM_EXAMPLE.md new file mode 100644 index 00000000..be1dabb7 --- /dev/null +++ b/containers/2_ApplicationSpecific/R-Rocker_Project/SLURM_EXAMPLE.md @@ -0,0 +1,75 @@ +# R_rocker Slurm example + +Change to your R directory + +``` +cd /projects/academic/[YourGroupName]/R +``` + +Download the slurm sample scrip and the exmaple R script [estimate_pi.R](https://raw.githubusercontent.com/tonykew/ccr-examples/refs/heads/R-Rocker_Project/containers/2_ApplicationSpecific/R-Rocker_Project/estimate_pi.R) +The example code is writen by Andrea Gustafsen - see: +https://rpubs.com/andrea_gustafsen/839901 + +``` +test -f estimate_pi.R || curl -o estimate_pi.R https://raw.githubusercontent.com/tonykew/ccr-examples/refs/heads/R-Rocker_Project/containers/2_ApplicationSpecific/R-Rocker_Project/estimate_pi.R +test -f slurm_example.bash || curl -o slurm_example.bash https://raw.githubusercontent.com/tonykew/ccr-examples/refs/heads/R-Rocker_Project/containers/2_ApplicationSpecific/R-Rocker_Project/slurm_example.bash +``` + +sample output: + +> ``` +> % Total % Received % Xferd Average Speed Time Time Time Current +> Dload Upload Total Spent Left Speed +> 100 874 100 874 0 0 14577 0 --:--:-- --:--:-- --:--:-- 14813 +> % Total % Received % Xferd Average Speed Time Time Time Current +> Dload Upload Total Spent Left Speed +> 100 1434 100 1434 0 0 12964 0 --:--:-- --:--:-- --:--:-- 13036 +> ``` + +Modify the Slurm script - change the cluster, partition, qos and account +You can use the `slimits` command to see what accounts and QOS settings yoa +have access to. + +For example: + +``` +cat slurm_example.bash +``` + +abridged sample output: + +> ``` +> [...] +#SBATCH --cluster="ub-hpc" +#SBATCH --partition="debug" +#SBATCH --qos="debug" +#SBATCH --account="ccradmintest" +> [...] +> ``` + +Submit the Slurm script + +``` +sbatch ./slurm_example.bash +``` + +sample output: + +> ``` +> Submitted batch job 22173265 on cluster ub-hpc +> ``` + +The Slurm output file in this case is slurm-22173265.out +Once this Slurm job completed: + +``` +cat slurm-22173265.out +``` + +> ``` +> 10 100 1000 10000 1e+05 1e+06 1e+07 1e+08 +> 2.400000 3.160000 3.184000 3.158400 3.138760 3.143816 3.141868 3.141650 +> 1e+09 +> 3.141679 +> ``` + From 522f4fd456abf0a08a8a66db21e6e7c289d1ffc3 Mon Sep 17 00:00:00 2001 From: Tony Kew Date: Thu, 23 Oct 2025 17:44:41 -0400 Subject: [PATCH 3/8] Added links to Slurm example docs & updated the menu README.md Tony --- containers/2_ApplicationSpecific/R-Rocker_Project/README.md | 6 ++++-- containers/2_ApplicationSpecific/README.md | 1 + 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/containers/2_ApplicationSpecific/R-Rocker_Project/README.md b/containers/2_ApplicationSpecific/R-Rocker_Project/README.md index ea8131de..c8532833 100644 --- a/containers/2_ApplicationSpecific/R-Rocker_Project/README.md +++ b/containers/2_ApplicationSpecific/R-Rocker_Project/README.md @@ -252,10 +252,12 @@ See the [EXAMPLES file](./EXAMPLES.md) for more info. Slurm script examples: ### x86_64 example -[R example](https://raw.githubusercontent.com/tonykew/ccr-examples/refs/heads/R-Rocker_Project/containers/2_ApplicationSpecific/R-Rocker_Project/slurm_example.bash) +[R x86_64 Slurm example script](https://raw.githubusercontent.com/tonykew/ccr-examples/refs/heads/R-Rocker_Project/containers/2_ApplicationSpecific/R-Rocker_Project/slurm_example.bash) +[Docs for running the R x86_64 Slurm example script](./SLURM_EXAMPLE.md) ### ARM64 example -[R ARM64 example](https://raw.githubusercontent.com/ubccr/ccr-examples/refs/heads/R-Rocker_Project/containers/2_ApplicationSpecific/R-Rocker_Project/slurm_ARM64_example.bash) +[R ARM64 Slurm example script](https://raw.githubusercontent.com/ubccr/ccr-examples/refs/heads/R-Rocker_Project/containers/2_ApplicationSpecific/R-Rocker_Project/slurm_ARM64_example.bash) +[Docs for running the R ARM64 Slurm example script](./SLURM_ARM64_EXAMPLE.md) ## Documentation Resources diff --git a/containers/2_ApplicationSpecific/README.md b/containers/2_ApplicationSpecific/README.md index 25c4ef32..8bcd2327 100644 --- a/containers/2_ApplicationSpecific/README.md +++ b/containers/2_ApplicationSpecific/README.md @@ -17,6 +17,7 @@ Please refer to CCR's [container documentation](https://docs.ccr.buffalo.edu/en/ | [OpenFF-Toolkit](./Open_Force_Field_toolkit) | Open Force Field toolkit container with steps for building and running via Apptainer | | [OpenFOAM](./OpenFOAM) | OpenFOAM container with steps for building and running via Apptainer and Slurm | | [OpenSees](./OpenSees) | OpenSees container with steps for building and running via Apptainer | +| [R - Rocker Project](./R-Rocker_Project) | R container based on the Rocker Project "r-ver" image - Apptainer build, run and Slurm scripts | | [SAS](./sas) | Guide for running SAS using Apptainer via Slurm batch script, command line, and GUI access | | [Seurat](./seurat) | Seurat container with example scRNA analysis | | [VASP](./vasp) | Example VASP container with steps for building and running via Apptainer | From e5aebfd28fe80ce37b120c309d79c5981657ee6e Mon Sep 17 00:00:00 2001 From: Tony Kew Date: Thu, 23 Oct 2025 17:51:59 -0400 Subject: [PATCH 4/8] Fix formatting Tony --- .../R-Rocker_Project/SLURM_ARM64_EXAMPLE.md | 2 +- .../R-Rocker_Project/SLURM_EXAMPLE.md | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/containers/2_ApplicationSpecific/R-Rocker_Project/SLURM_ARM64_EXAMPLE.md b/containers/2_ApplicationSpecific/R-Rocker_Project/SLURM_ARM64_EXAMPLE.md index e4079a20..119f7144 100644 --- a/containers/2_ApplicationSpecific/R-Rocker_Project/SLURM_ARM64_EXAMPLE.md +++ b/containers/2_ApplicationSpecific/R-Rocker_Project/SLURM_ARM64_EXAMPLE.md @@ -52,7 +52,7 @@ abridged sample output: > ``` > [...] -#SBATCH --account="ccradmintest" +> #SBATCH --account="ccradmintest" > [...] > ``` diff --git a/containers/2_ApplicationSpecific/R-Rocker_Project/SLURM_EXAMPLE.md b/containers/2_ApplicationSpecific/R-Rocker_Project/SLURM_EXAMPLE.md index be1dabb7..92b2c0d4 100644 --- a/containers/2_ApplicationSpecific/R-Rocker_Project/SLURM_EXAMPLE.md +++ b/containers/2_ApplicationSpecific/R-Rocker_Project/SLURM_EXAMPLE.md @@ -40,10 +40,10 @@ abridged sample output: > ``` > [...] -#SBATCH --cluster="ub-hpc" -#SBATCH --partition="debug" -#SBATCH --qos="debug" -#SBATCH --account="ccradmintest" +> #SBATCH --cluster="ub-hpc" +> #SBATCH --partition="debug" +> #SBATCH --qos="debug" +> #SBATCH --account="ccradmintest" > [...] > ``` From 4285c493ed99193d8ce50a27bb3cd1666215a201 Mon Sep 17 00:00:00 2001 From: Tony Kew Date: Fri, 24 Oct 2025 10:06:49 -0400 Subject: [PATCH 5/8] Fixed ARM64 slurm script Tony --- .../R-Rocker_Project/SLURM_ARM64_EXAMPLE.md | 6 +++--- .../R-Rocker_Project/slurm_ARM64_example.bash | 4 +++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/containers/2_ApplicationSpecific/R-Rocker_Project/SLURM_ARM64_EXAMPLE.md b/containers/2_ApplicationSpecific/R-Rocker_Project/SLURM_ARM64_EXAMPLE.md index 119f7144..a5c70554 100644 --- a/containers/2_ApplicationSpecific/R-Rocker_Project/SLURM_ARM64_EXAMPLE.md +++ b/containers/2_ApplicationSpecific/R-Rocker_Project/SLURM_ARM64_EXAMPLE.md @@ -65,14 +65,14 @@ sbatch ./slurm_ARM64_example.bash sample output: > ``` -> Submitted batch job 22173297 on cluster ub-hpc +> Submitted batch job 22179954 on cluster ub-hpc > ``` -The Slurm output file in this case is slurm-22173297.out +The Slurm output file in this case is slurm-22179954.out Once this Slurm job completed: ``` -cat slurm-22173297.out +cat slurm-22179954.out ``` > ``` diff --git a/containers/2_ApplicationSpecific/R-Rocker_Project/slurm_ARM64_example.bash b/containers/2_ApplicationSpecific/R-Rocker_Project/slurm_ARM64_example.bash index 597a51e5..5850b589 100755 --- a/containers/2_ApplicationSpecific/R-Rocker_Project/slurm_ARM64_example.bash +++ b/containers/2_ApplicationSpecific/R-Rocker_Project/slurm_ARM64_example.bash @@ -8,8 +8,10 @@ #SBATCH --cluster="ub-hpc" #SBATCH --partition="arm64" #SBATCH --qos="arm64" +## Make sure the x86_64 (head node) environment is not used on the ARM64 node +#SBATCH --export=HOME,TERM,SHELL -## Select an account that has access to the arm64 partition (see `slimits | grep arm64`) +## Select an account that has access to the arm64 partition (see "slimits | grep arm64") #SBATCH --account="[SlurmAccountName]" ## Job runtime limit, the job will be canceled once this limit is reached. Format- dd-hh:mm:ss From 02ee512cf884fe4d947bb00b86fa61c56163122f Mon Sep 17 00:00:00 2001 From: Tony Kew Date: Fri, 24 Oct 2025 10:31:56 -0400 Subject: [PATCH 6/8] Clarify "slimits" output & fix a typo Tony --- .../R-Rocker_Project/SLURM_ARM64_EXAMPLE.md | 4 ++-- .../2_ApplicationSpecific/R-Rocker_Project/SLURM_EXAMPLE.md | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/containers/2_ApplicationSpecific/R-Rocker_Project/SLURM_ARM64_EXAMPLE.md b/containers/2_ApplicationSpecific/R-Rocker_Project/SLURM_ARM64_EXAMPLE.md index a5c70554..bf67b923 100644 --- a/containers/2_ApplicationSpecific/R-Rocker_Project/SLURM_ARM64_EXAMPLE.md +++ b/containers/2_ApplicationSpecific/R-Rocker_Project/SLURM_ARM64_EXAMPLE.md @@ -41,8 +41,8 @@ sample output: > ub-hpc ccradmintest tkewtest arm64,class,debug,eai-test,general-compute,industry,scavenger,viz > ``` -So my test account has access to the "arm64" partition using the account -"ccradmintest" +The second field in the Slurm account name, so my test account has access to +the "arm64" partition using the account "ccradmintest" ``` cat slurm_ARM64_example.bash diff --git a/containers/2_ApplicationSpecific/R-Rocker_Project/SLURM_EXAMPLE.md b/containers/2_ApplicationSpecific/R-Rocker_Project/SLURM_EXAMPLE.md index 92b2c0d4..73cc0c57 100644 --- a/containers/2_ApplicationSpecific/R-Rocker_Project/SLURM_EXAMPLE.md +++ b/containers/2_ApplicationSpecific/R-Rocker_Project/SLURM_EXAMPLE.md @@ -27,7 +27,7 @@ sample output: > ``` Modify the Slurm script - change the cluster, partition, qos and account -You can use the `slimits` command to see what accounts and QOS settings yoa +You can use the `slimits` command to see what accounts and QOS settings you have access to. For example: From 03cf084ae7824c4c9102d4952dba13035cc92672 Mon Sep 17 00:00:00 2001 From: Tony Kew Date: Fri, 24 Oct 2025 18:24:20 -0400 Subject: [PATCH 7/8] Added "slimits" examples for Slurm account information Use SALLOC_ACCOUNT for the Slurm account name so the following "salloc" code block can be copied & pasted without change. Tried using SALLOC_[...] variables for all the "salloc" settings, infortunately there are not SALLOC veraibles for several "salloc" options such as "--nodes=" "--ntasks-per-node=" and "--cpus-per-task=" The end result may be worse than before... Tony --- .../R-Rocker_Project/BUILD-ARM64.md | 44 ++++++++- .../R-Rocker_Project/EXAMPLE.md | 34 ++++++- .../R-Rocker_Project/README.md | 95 ++++++++++++++++--- .../R-Rocker_Project/SLURM_ARM64_EXAMPLE.md | 8 +- .../R-Rocker_Project/SLURM_EXAMPLE.md | 2 +- 5 files changed, 163 insertions(+), 20 deletions(-) diff --git a/containers/2_ApplicationSpecific/R-Rocker_Project/BUILD-ARM64.md b/containers/2_ApplicationSpecific/R-Rocker_Project/BUILD-ARM64.md index acf1f279..a4c9f52d 100644 --- a/containers/2_ApplicationSpecific/R-Rocker_Project/BUILD-ARM64.md +++ b/containers/2_ApplicationSpecific/R-Rocker_Project/BUILD-ARM64.md @@ -5,6 +5,36 @@ 1. Start an interactive job on an ARM64 node +You can use the `slimits` command to see what accounts and QOS settings you +have access to. + +To find which Slurm account you can use to run an interactive job in the "arm64" +partition: + +``` +slimits | grep "arm64" +``` + +sample output: + +> ``` +> ub-hpc SlurmAccountName CCRusername arm64,debug,general-compute,scavenger,viz +> ``` + +The second field in the Slurm account name, so my test account has access to +the "arm64" partition using the account "SlurmAccountName" + +Set the environment variable "SBATCH_ACCOUNT" to the Slurm account you want +to use. +e.g. + +``` +export SBATCH_ACCOUNT="SlurmAccountName" +``` + +You can now start an interactive job in the "arm64" partition with the +following: + ``` tmp_file="$(mktemp)" salloc --partition=arm64 --qos=arm64 --constraint=ARM64 --no-shell \ @@ -113,7 +143,7 @@ End the Slurm job ``` scancel "${SLURM_JOB_ID}" -unset SLURM_JOB_ID +unset SLURM_JOB_ID SBATCH_ACCOUNT ``` 4. Running the container @@ -130,6 +160,16 @@ Notes: GPU(s) e.g. "--gpus-per-node=1" and add tht "--nv" opion to apptainer so the requested GPU(s) are available inside the container. +Set the Slurm account you want to use for this interactive job (see `slimits` +for the account(s) you can use + +``` +export SBATCH_ACCOUNT="SlurmAccountName" +``` + +You can now start an interactive job in the "arm64" partition with the +following: + ``` tmp_file="$(mktemp)" salloc --partition=arm64 --qos=arm64 --constraint=ARM64 --no-shell \ @@ -238,6 +278,6 @@ End the Slurm job ``` scancel "${SLURM_JOB_ID}" -unset SLURM_JOB_ID +unset SLURM_JOB_ID SBATCH_ACCOUNT ``` diff --git a/containers/2_ApplicationSpecific/R-Rocker_Project/EXAMPLE.md b/containers/2_ApplicationSpecific/R-Rocker_Project/EXAMPLE.md index aa2db49a..1d7889a3 100644 --- a/containers/2_ApplicationSpecific/R-Rocker_Project/EXAMPLE.md +++ b/containers/2_ApplicationSpecific/R-Rocker_Project/EXAMPLE.md @@ -2,11 +2,41 @@ Start an interactive job in the "debug" partition +You can use the `slimits` command to see what accounts and QOS settings you +have access to. + +To find which Slurm account you can use to run an interactive job in the debug +partition: + +``` +slimits | grep "debug" +``` + +sample output: + +> ``` +> ub-hpc SlurmAccountName CCRusername arm64,debug,general-compute,scavenger,viz +> ``` + +The second field in the Slurm account name, so this example has access to the +"debug" partition using the Slurm account "SlurmAccountName" + +Set the environment variable "SBATCH_ACCOUNT" to the Slurm account you want +to use. +e.g. + +``` +export SBATCH_ACCOUNT="SlurmAccountName" +``` + +You can now start an interactive job in the "debug" partition with the +following: + ``` tmp_file="$(mktemp)" salloc --cluster=ub-hpc --partition=debug --qos=debug --no-shell \ --nodes=1 --cpus-per-task=1 --tasks-per-node=6 --mem=36GB \ - --account="[SlurmAccountName]" --time=1:00:00 2>&1 | tee "${tmp_file}" + --time=1:00:00 2>&1 | tee "${tmp_file}" SLURM_JOB_ID="$(head -1 "${tmp_file}" | awk '{print $NF}')" rm "${tmp_file}" srun --jobid="${SLURM_JOB_ID}" --export=HOME,TERM,SHELL --pty /bin/bash --login @@ -97,6 +127,6 @@ End the Slurm job ``` scancel "${SLURM_JOB_ID}" -unset SLURM_JOB_ID +unset SLURM_JOB_ID SBATCH_ACCOUNT ``` diff --git a/containers/2_ApplicationSpecific/R-Rocker_Project/README.md b/containers/2_ApplicationSpecific/R-Rocker_Project/README.md index c8532833..8b76d305 100644 --- a/containers/2_ApplicationSpecific/R-Rocker_Project/README.md +++ b/containers/2_ApplicationSpecific/R-Rocker_Project/README.md @@ -10,19 +10,62 @@ reproducibility. ## Building the container A brief guide to building the R_rocker container follows:
-Please refer to CCR's [container documentation](https://docs.ccr.buffalo.edu/en/latest/howto/containerization/) for more detailed information on building and using Apptainer. +Please refer to CCR's [container documentation](https://docs.ccr.buffalo.edu/en/latest/howto/containerization/) for more detailed information on +building and using Apptainer. NOTE: for building on the ARM64 platform see [BUILD-ARM64.md](./BUILD-ARM64.md) -1. Start an interactive job +1. Start an interactive job in the "debug" partition -Apptainer is not available on the CCR login nodes and the compile nodes may not provide enough resources for you to build a container. We recommend requesting an interactive job on a compute node to conduct this build process.
+Apptainer is not available on the CCR login nodes and the compile nodes may not +provide enough resources for you to build a container. We recommend requesting +an interactive job on a compute node to conduct this build process.
See CCR docs for more info on [running jobs](https://docs.ccr.buffalo.edu/en/latest/hpc/jobs/#interactive-job-submission) +You can use the `slimits` command to see what accounts and QOS settings you +have access to. +For example, to find the Slurm accoun(s) you can use to run an interactive job +in the "debug" partition: + +``` +slimits | grep "debug" +``` + +sample output: + +> ``` +> ub-hpc SlurmAccountName CCRusername arm64,debug,general-compute,scavenger,viz +> ``` + +The second field in the Slurm account name, so this example has access to the +"debug" partition using the Slurm account "SlurmAccountName" + +Set the environment variable "SALLOC_ACCOUNT" to the Slurm account you want +to use. +e.g. + +``` +export SALLOC_ACCOUNT="SlurmAccountName" +``` + +The following variables will request exclusive use of a "debug" partition node +for an hour with the salloc comand that follows + +``` +export SALLOC_CLUSTERS="ub-hpc" +export SALLOC_PARTITION="debug" +export SALLOC_QOS="debug" +export SALLOC_EXCLUSIVE="" +export SALLOC_MEM_PER_NODE="0" +export SALLOC_TIMELIMIT="01:00:00" +``` + +You can now start an interactive job in the "debug" partition with the +following: + ``` tmp_file="$(mktemp)" -salloc --cluster=ub-hpc --partition=debug --qos=debug --no-shell --exclusive \ - --account="[SlurmAccountName]" --mem=0 --time=1:00:00 2>&1 | tee "${tmp_file}" +salloc --nodes=1 --no-shell 2>&1 | tee "${tmp_file}" SLURM_JOB_ID="$(head -1 "${tmp_file}" | awk '{print $NF}')" rm "${tmp_file}" srun --jobid="${SLURM_JOB_ID}" --export=HOME,TERM,SHELL --pty /bin/bash --login @@ -123,22 +166,52 @@ sample output: > CCRusername@login1$ > ``` -End the Slurm job +End the Slurm job and remove the environment variables set for the job ``` scancel "${SLURM_JOB_ID}" unset SLURM_JOB_ID +eval $(set | grep ^SALLOC_ | awk -F= '{print "unset " $1}') ``` 4. Running the container -Start an interactive job e.g. +Start an interactive job - the following example uses the "general-compute" +partition + +To find which Slurm account you can use to run an interactive job in the +"general-compute" partition: + +``` +slimits | grep "general-compute" +``` + +sample output: + +> ``` +> ub-hpc SlurmAccountName CCRusername arm64,debug,general-compute,scavenger,viz +> ``` + + +The second field in the Slurm account name, so this example has access to the +"general-compute" partition using the Slurm account "SlurmAccountName" + +Set the environment variable "SALLOC_ACCOUNT" to the Slurm account you want +to use. +e.g. + +``` +export SALLOC_ACCOUNT="SlurmAccountName" +``` + +This example runs an interactive job in the "general-compute" partition, with +64GB RAM and 6 cores on a single node for 5 hours: ``` tmp_file="$(mktemp)" salloc --cluster=ub-hpc --partition=general-compute --qos=general-compute \ - --no-shell --mem=128GB --nodes=1 --cpus-per-task=1 --tasks-per-node=12 \ - --account="[SlurmAccountName]" --time=5:00:00 2>&1 | tee "${tmp_file}" + --no-shell --mem=64GB --nodes=1 --cpus-per-task=1 --tasks-per-node=6 \ + --time=5:00:00 2>&1 | tee "${tmp_file}" SLURM_JOB_ID="$(head -1 "${tmp_file}" | awk '{print $NF}')" rm "${tmp_file}" srun --jobid="${SLURM_JOB_ID}" --export=HOME,TERM,SHELL --pty /bin/bash --login @@ -237,11 +310,11 @@ sample output: > CCRusername@login1$ > ``` -End the Slurm job +End the Slurm job and remove the environment variables set for the job ``` scancel "${SLURM_JOB_ID}" -unset SLURM_JOB_ID +unset SLURM_JOB_ID SALLOC_ACCOUNT ``` diff --git a/containers/2_ApplicationSpecific/R-Rocker_Project/SLURM_ARM64_EXAMPLE.md b/containers/2_ApplicationSpecific/R-Rocker_Project/SLURM_ARM64_EXAMPLE.md index bf67b923..cca1d276 100644 --- a/containers/2_ApplicationSpecific/R-Rocker_Project/SLURM_ARM64_EXAMPLE.md +++ b/containers/2_ApplicationSpecific/R-Rocker_Project/SLURM_ARM64_EXAMPLE.md @@ -38,11 +38,11 @@ slimits | grep arm64 sample output: > ``` -> ub-hpc ccradmintest tkewtest arm64,class,debug,eai-test,general-compute,industry,scavenger,viz +> ub-hpc SlurmAccountName CCRusername arm64,debug,general-compute,scavenger,viz > ``` -The second field in the Slurm account name, so my test account has access to -the "arm64" partition using the account "ccradmintest" +The second field in the Slurm account name, so this example has access to the +"arm64" partition using the Slurm account "SlurmAccountName" ``` cat slurm_ARM64_example.bash @@ -52,7 +52,7 @@ abridged sample output: > ``` > [...] -> #SBATCH --account="ccradmintest" +> #SBATCH --account="SlurmAccountName" > [...] > ``` diff --git a/containers/2_ApplicationSpecific/R-Rocker_Project/SLURM_EXAMPLE.md b/containers/2_ApplicationSpecific/R-Rocker_Project/SLURM_EXAMPLE.md index 73cc0c57..323b09c7 100644 --- a/containers/2_ApplicationSpecific/R-Rocker_Project/SLURM_EXAMPLE.md +++ b/containers/2_ApplicationSpecific/R-Rocker_Project/SLURM_EXAMPLE.md @@ -43,7 +43,7 @@ abridged sample output: > #SBATCH --cluster="ub-hpc" > #SBATCH --partition="debug" > #SBATCH --qos="debug" -> #SBATCH --account="ccradmintest" +> #SBATCH --account="SlurmAccountName" > [...] > ``` From 416f82cc100a2feac285362662a0e7b1eec286d5 Mon Sep 17 00:00:00 2001 From: Tony Kew Date: Mon, 3 Nov 2025 10:12:28 -0500 Subject: [PATCH 8/8] Add the 32bit openblas (as well as the 64 bit openblas) Tony --- .../2_ApplicationSpecific/R-Rocker_Project/R_rocker_4.5.1.def | 2 ++ 1 file changed, 2 insertions(+) diff --git a/containers/2_ApplicationSpecific/R-Rocker_Project/R_rocker_4.5.1.def b/containers/2_ApplicationSpecific/R-Rocker_Project/R_rocker_4.5.1.def index 8df8784e..a1f89abb 100644 --- a/containers/2_ApplicationSpecific/R-Rocker_Project/R_rocker_4.5.1.def +++ b/containers/2_ApplicationSpecific/R-Rocker_Project/R_rocker_4.5.1.def @@ -132,6 +132,8 @@ From: ghcr.io/rocker-org/r-ver:4.5.1 libhtscodecs-dev \ libopenblas64-0 \ libopenblas64-dev \ + libopenblas-dev \ + libopenblas64-dev \ liblapack3 \ liblapack-dev \ liblapacke-dev \