Changes between Version 26 and Version 27 of cypress/R


Ignore:
Timestamp:
08/19/25 14:32:43 (42 hours ago)
Author:
cbaribault
Comment:

Updating content for workshop, part 2

Legend:

Unmodified
Added
Removed
Modified
  • cypress/R

    v26 v27  
    1717}}}
    1818
     19=== Using Intel's Math Kernel Library (MKL) ===
     20
    1921Observe in the output above that some R modules have names ending with the string 'intel'.
    2022These modules have been constructed with links to Intel's Math Kernel Library (MKL) for performing certain computations using the Xeon Phi coprocessors.
    2123See [[cypress/XeonPhi]].
    2224
    23 Also, the later versions of R require a later version, CentOS 7, of the operating system running on compute nodes in their own SLURM partition.
     25=== Using CentOS 7 Operating System ===
     26
     27Also, the later versions of R are available only on compute nodes using the later version, CentOS 7, of the operating system available in a separate SLURM partition. For more information, see [[cypress/using#Requestingpartitioncentos7withglibc2.17|Requesting partition centos7 (batch)]] and also [[cypress/using#Requestingpartitioncentos7|Requesting partition centos7 (interactive)]].
    2428
    2529== Running R Interactively ==
     
    2731=== Start an interactive session using idev ===
    2832
    29 In the following we'll use the latest version of R available.
     33In the following we'll use the latest version of R available, which runs only on compute nodes in turn running with version CentOS 7 operating system.
    3034
    3135==== For Workshop ====
    3236
    33 If the primary group of your account is '''workshop''', then in order to use only 2 cpu's per node and thus allow for sharing the few available nodes in the interactive partition among many users, do this.
    34 
    35 {{{
    36 export MY_PARTITION=workshop
    37 export MY_QUEUE=workshop
    38 [tulaneID@cypress1 ~]$ idev -c 2
     37If your account is in the group '''workshop''', then in order to use only 2 cpu's per node and thus allow for sharing the few available nodes in the '''workshop7''' partition among many users, do this.
     38
     39{{{
     40[tulaneID@cypress1 ~]$export MY_PARTITION=workshop7
     41[tulaneID@cypress1 ~]$export MY_QUEUE=workshop
     42}}}
     43
     44{{{
     45[tulaneID@cypress1 ~]$idev -c 2
     46Requesting 1 node(s)  task(s) to workshop queue of workshop7 partition
     471 task(s)/node, 2 cpu(s)/task, 0 MIC device(s)/node
     48Time: 0 (hr) 60 (min).
     490d 0h 60m
     50Submitted batch job 2706829
     51JOBID=2706829 begin on cypress01-009
     52--> Creating interactive terminal session (login) on node cypress01-009.
     53--> You have 0 (hr) 60 (min).
     54--> Assigned Host List : /tmp/idev_nodes_file_tulaneID
     55Last login: Tue Aug 19 10:30:58 2025 from cypress2.cm.cluster
     56[tulaneID@cypress01-009 ~ at 12:12:10]$
    3957}}}
    4058
    4159
    4260==== Non-workshop ====
     61
     62{{{
     63export MY_PARTITION=centos7
     64}}}
     65
    4366{{{
    4467[tulaneID@cypress1 ~]$ idev
     
    5073--> Creating interactive terminal session (login) on node cypress01-121.
    5174--> You have 0 (hr) 60 (min).
    52 --> Assigned Host List : /tmp/idev_nodes_file_tuhpc002
     75--> Assigned Host List : /tmp/idev_nodes_file_tulaneID
    5376Last login: Wed Aug 21 15:56:37 2019 from cypress1.cm.cluster
    5477[tulaneID@cypress01-121 ~]$
     
    5881
    5982{{{
    60 [tulaneID@cypress01-121 ~]$ module load R/4.1.1-intel
     83[tulaneID@cypress01-121 ~]$ module load R/4.4.1
    6184[tulaneID@cypress01-121 ~]$ module list
    6285Currently Loaded Modulefiles:
    63   1) slurm/14.03.0             6) mpfr/4.1.0               11) xz/5.2.2                 16) libtiff/4.3.0
    64   2) idev                      7) mpc/1.2.1                12) pcre2/10.38              17) R/4.1.1-intel
    65   3) bbcp/amd64_rhel60         8) gcc/6.3.0                13) tcl/8.6.11
    66   4) intel-psxe/2019-update1   9) zlib/1.2.8               14) tk/8.6.11
    67   5) gmp/6.2.1                10) bzip2/1.0.6              15) libpng/1.6.37
     86  1) slurm/14.03.0           6) mpc/1.2.1              11) pcre2/10.38            16) libtiff/4.6.0
     87  2) idev                    7) gcc/9.5.0              12) tcl/8.6.11             17) tre/0.8.0
     88  3) bbcp/amd64_rhel60       8) zlib/1.2.8             13) tk/8.6.11              18) binutils/2.37
     89  4) gmp/6.2.1               9) bzip2/1.0.6            14) libpng/1.6.37          19) java-openjdk/17.0.7+7
     90  5) mpfr/4.1.0             10) xz/5.2.2               15) libjpeg-turbo/3.0.1    20) R/4.4.1
    6891}}}
    6992
     
    7396[tulaneID@cypress01-121 ~]$R
    7497
    75 R version 4.1.1 (2021-08-10) -- "Kick Things"
    76 Copyright (C) 2021 The R Foundation for Statistical Computing
    77 Platform: x86_64-pc-linux-gnu (64-bit)
     98R version 4.4.1 (2024-06-14) -- "Race for Your Life"
     99Copyright (C) 2024 The R Foundation for Statistical Computing
     100Platform: x86_64-pc-linux-gnu
    78101
    79102R is free software and comes with ABSOLUTELY NO WARRANTY.
     
    101124}}}
    102125
    103 Thus we should first ensure that the required R package, in this case the R package '''doParallel''', is available and installed in your environment. For a range of options for installing R packages - depending on the desired level of reproducibility, see the section [#InstallingRPackages Installing R Packages on Cypress].
     126To resolve the above error, we should first ensure that the required R package, in this case the R package '''doParallel''', is available and installed in your environment. For a range of options for installing R packages - depending on the desired level of reproducibility, see the section [#InstallingRPackages Installing R Packages on Cypress].
    104127
    105128'''For Workshop''' :
    106 If you use a temporary workshop account, use [#RPackageAlternative1 Alternative 1] - responding to the R prompts as needed - for installing R packages such as in the following.
     129If your account is in the group '''workshop''', use [[cypress/InstallingRPackages#Alternative1-defaulttohomesub-directory | Alternative 1]] - responding to the R prompts as needed - for installing R packages such as in the following.
    107130
    108131Thus we need to install the R package '''doParallel'''.
     
    119142> q()
    120143Save workspace image? [y/n/c]: n
    121 [tuhpc002@cypress01-121 R]$ exit
    122 }}}
    123 
    124 Thus, now that we have resolved our package dependency, we can expect future jobs requiring '''doParallel''' to run without errors.
     144[tulaneID@cypress01-121 ~]$exit
     145[tulaneID@cypress1 ~]$
     146}}}
     147
     148Now that we have resolved our package dependency, we can expect future jobs requiring '''doParallel''' to run without errors.
     149
     150Also, notice in the above that we have exited the interactive session since we no longer need it to submit batch jobs.
     151
     152== Download Sample Scripts ==
     153
     154If you have not done yet, '''download Sample files''' by:
     155
     156{{{[tulaneID@cypress1 ~]$ git clone https://hidekiCCS:@bitbucket.org/hidekiCCS/hpc-workshop.git}}}
     157
     158Then use the '''cp''' command to copy the batch scripst and R scripts to your current directory.
     159
     160{{{cp hpc-workshop/R/* .}}}
    125161
    126162== Running a R script in Batch mode ==
     
    130166{{{#!sh
    131167#!/bin/bash
     168#SBATCH --partition=centos7     # Partition
    132169#SBATCH --qos=normal            # Quality of Service
    133170#SBATCH --job-name=R            # Job Name
     
    137174#SBATCH --cpus-per-task=1       # Number of threads per task (OMP threads)
    138175
    139 module load R/3.2.4
     176module load R/4.4.1
    140177Rscript myRscript.R
    141178}}}
    142179
    143180'''For Workshop''' :
    144 If you use a temporary workshop account, modify the SLURM script like:
    145 {{{#!sh
    146 #!/bin/bash
    147 #SBATCH --partition=workshop    # Partition
    148 #SBATCH --qos=workshop          # Quality of Service
    149 ##SBATCH --qos=normal          ### Quality of Service (like a queue in PBS)
     181If your account is in the group '''workshop''', modify the SLURM script like:
     182{{{#!sh
     183#!/bin/bash
     184#SBATCH --partition=workshop7   # Partition
     185#SBATCH --qos=workshop          # Quality of Service
     186##SBATCH --qos=normal           ### Quality of Service (like a queue in PBS)
    150187#SBATCH --job-name=R            # Job Name
    151188#SBATCH --time=00:01:00         # WallTime
     
    154191#SBATCH --cpus-per-task=1       # Number of threads per task (OMP threads)
    155192
    156 module load R/3.2.4
     193module load R/4.4.1
    157194Rscript myRscript.R
    158195}}}
     
    166203In the first example, we will use the built in R function '''Sys.getenv( )''' to get the SLURM environment variable from the operating system.
    167204
    168 Edit the new file '''bootstrap.R''' to contain the following code.
     205Let's look at the downloaded sample file '''bootstrap.R''' containing the following code.
    169206
    170207{{{#!r
     
    200237{{{#!sh
    201238#!/bin/bash
     239#SBATCH --partition=centos7     # Partition
    202240#SBATCH --qos=normal            # Quality of Service
    203241#SBATCH --job-name=R            # Job Name
    204242#SBATCH --time=00:01:00         # WallTime
    205243#SBATCH --nodes=1               # Number of Nodes
    206 #SBATCH --ntasks-per-node=1    # Number of Tasks per Node
     244#SBATCH --ntasks-per-node=1     # Number of Tasks per Node
    207245#SBATCH --cpus-per-task=16      # Number of threads per task (OMP threads)
    208246
    209 module load R/3.2.4
     247module load R/4.4.1
    210248
    211249Rscript bootstrap.R
     
    213251
    214252'''For Workshop''' :
    215 If you use a temporary workshop account, modify the SLURM script like:
    216 {{{#!sh
    217 #!/bin/bash
    218 #SBATCH --partition=workshop    # Partition
     253If your account is in the group '''workshop''', modify the SLURM script like:
     254{{{#!sh
     255#!/bin/bash
     256#SBATCH --partition=workshop7   # Partition
    219257#SBATCH --qos=workshop          # Quality of Service
    220258##SBATCH --qos=normal          ### Quality of Service (like a queue in PBS)
     
    225263#SBATCH --cpus-per-task=16      # Number of threads per task (OMP threads)
    226264
    227 module load R/3.2.4
     265module load R/4.4.1
    228266
    229267Rscript bootstrap.R
    230268}}}
    231269
    232 Edit the new file '''bootstrap.sh''' to contain the above SLURM script code and submit as shown below.
     270The downloaded sample file '''bootstrap.sh''' contains the above SLURM script code, and we can submit as shown below.
    233271
    234272Also, note that since we did not specify an output file in the SLURM script, the output will be written to slurm-<!JobNumber>.out. For example:
    235273
    236274{{{
    237 [tulaneID@cypress2 R]$ sbatch bootstrap.sh
     275[tulaneID@cypress2 ~]$ sbatch bootstrap.sh
    238276Submitted batch job 774081
    239 [tulaneID@cypress2 R]$ cat slurm-774081.out
     277[tulaneID@cypress2 ~]$ cat slurm-774081.out
    240278Loading required package: foreach
    241279Loading required package: iterators
     
    244282elapsed
    245283  2.954
    246 [tulaneID@cypress2 R]$
     284[tulaneID@cypress2 ~]$
    247285}}}
    248286
     
    251289=== Passing Parameters ===
    252290
    253 The disadvantage of the above approach is that it is system specific. If we move our code to a machine that uses PBS-Torque as it's manager (sphynx for example) we have to change our source code. An alternative method that results in a more portable code base uses command line arguments to pass the value of our environment variables into the script.
    254 
    255 Edit the new file '''bootstrapWargs.R''' to contain the following code.
     291The disadvantage of the above approach is that it is system specific. If we move our code to a machine that uses PBS-Torque as it's manager ([[https://hpc.loni.org/resources/hpc/system.php?system=QB2|LONI QB2]] for example) we have to change our source code. An alternative method that results in a more portable code base uses command line arguments to pass the value of our environment variables into the script.
     292
     293Let's look at the downloaded file '''bootstrapWargs.R''' containing the following code.
    256294
    257295{{{#!r
     
    289327{{{#!sh
    290328#!/bin/bash
     329#SBATCH --partition=centos7     # Partition
    291330#SBATCH --qos=normal            # Quality of Service
    292331#SBATCH --job-name=R       # Job Name
     
    296335#SBATCH --cpus-per-task=16      # Number of threads per task (OMP threads)
    297336
    298 module load R/3.2.4
     337module load R/4.4.1
    299338
    300339Rscript bootstrapWargs.R $SLURM_CPUS_PER_TASK
     
    302341
    303342'''For Workshop''' :
    304 If you use a temporary workshop account, modify the SLURM script like:
    305 {{{#!sh
    306 #!/bin/bash
    307 #SBATCH --partition=workshop    # Partition
     343If your account is in the group '''workshop''', modify the SLURM script like:
     344{{{#!sh
     345#!/bin/bash
     346#SBATCH --partition=workshop7   # Partition
    308347#SBATCH --qos=workshop          # Quality of Service
    309348##SBATCH --qos=normal          ### Quality of Service (like a queue in PBS)
     
    314353#SBATCH --cpus-per-task=16      # Number of threads per task (OMP threads)
    315354
    316 module load R/3.2.4
     355module load R/4.4.1
    317356
    318357Rscript bootstrapWargs.R $SLURM_CPUS_PER_TASK
    319358}}}
    320359
    321 Edit the new file '''bootstrapWargs.sh''' to contain the above SLURM script code.
     360The downloaded file '''bootstrapWargs.sh''' contains the above SLURM script code.
    322361
    323362Now submit as in the following.