Module Python

Module Python

 

Interactive job

Open an interactive session to a compute node. Adjust the number of CPUs (--cpus-per-task 1) and the amount of memory (--mem 4G) needed for your job. Increase the number of --cpus-per-task only when using code that can run in parallel.

srun --cpus-per-task 1 --mem 4G --pty bash

Load R module.

module load R/4.4.1

Run R.

R
[user@athena1 ~]$ srun --cpus-per-task 1 --mem 4G --pty bash [user@athena101 ~]$ module load R/4.4.1 [user@athena101 ~]$ R R version 4.4.1 (2024-06-14) -- "Beagle Scouts" Copyright (C) 2023 The R Foundation for Statistical Computing Platform: x86_64-pc-linux-gnu (64-bit) 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. >

Batch job

Create the R script file.

R_script.R
myString <- "Hello, World!" print (myString)

Create the Slurm script file. Adjust the number of CPUs (--cpus-per-task 1) and the amount of memory (--mem 4G) needed for your job. Increase the number of --cpus-per-task only when using code that can run in parallel.

R_slurm_script.sh
#!/bin/bash #SBATCH --job-name R_job #SBATCH --output R_job_output.log #SBATCH --error R_job_error.log #SBATCH --cpus-per-task 1 #SBATCH --mem 4G module load R/4.4.1 Rscript R_script.R

Submit the job to Slurm.

sbatch R_slurm_script.sh

Monitor the execution of your job in the Slurm queue.

squeue -u $USER

The job may show up in the queue as running (R) or pending (PD). When the job completes, it will disappear from the queue and you can check the output.

[user@athena1 ~]$ sbatch R_slurm_script.sh Submitted batch job 123 [user@athena1 ~]$ squeue -u $USER JOBID PARTITION NAME USER ST TIME NODES NODELIST(REASON) ## Job is running with JOBID 123 123 cpu R_job user R 0:01 1 athena101 [user@athena1 ~]$ squeue -u $USER JOBID PARTITION NAME USER ST TIME NODES NODELIST(REASON) ## JOBID 123 completed and exited the queue [user@athena1 ~]$ cat R_job_output.log [1] "Hello, World!"