This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
|
howto:r [2013/02/19 12:57] dane R version change |
howto:r [2021/12/09 16:42] (current) |
||
|---|---|---|---|
| Line 1: | Line 1: | ||
| ====== Using R ====== | ====== Using R ====== | ||
| - | **R** is installed in ''/ | + | **R** has been installed in ''/ |
| < | < | ||
| - | module add openmpi/openmpi-1.6.1-gnu | + | module add chpc/R/3.2.3-gcc5.1.0 |
| </ | </ | ||
| - | to your **'' | + | to your scripts will set up the appropriate paths to R, the compilers (if you want to add your own R packages) and the mpi libraries. Note that there may be several versions of R installed and can be seen by running the: < |
| - | The '' | ||
| - | Once you've created your R script file, called '' | + | ===== Parallel R ===== |
| + | |||
| + | The '' | ||
| + | |||
| + | Once you've created your R script file, called '' | ||
| Example job script file: | Example job script file: | ||
| - | <code> | + | <file bash my_R_job.qsub> |
| #!/bin/bash | #!/bin/bash | ||
| - | #MSUB -l nodes=2:ppn=8 | + | #PBS -l select=2:ncpus=24: |
| - | #MSUB -l walltime=1:00:00 | + | #PBS -P SHORTNAME |
| - | #MSUB -V | + | #PBS -q normal |
| - | #MSUB -o /export/home/username/simulations/job-1.out | + | #PBS -l walltime=4:00:00 |
| - | #MSUB -e /export/home/username/simulations/job-1.err | + | #PBS -o /mnt/lustre/users/USERNAME/my_R_data/ |
| - | #MSUB -d / | + | #PBS -e /mnt/lustre/users/USERNAME/my_R_data/ |
| - | #MSUB -M be your_emall@address | + | #PBS -N RJob |
| - | #MSUB -q | + | #PBS -M myemailaddress@someplace.com |
| - | + | #PBS -m abe | |
| - | mpirun -np 16 / | + | |
| - | </code> | + | # Add R module (includes appropriate openMPI and gcc modules) |
| + | module add chpc/R/3.2.3-gcc5.1.0 | ||
| + | |||
| + | # explicitly calculate number of processes. | ||
| + | nproc=`cat $PBS_NODEFILE | wc -l` | ||
| + | |||
| + | # make sure we're in the correct working directory. | ||
| + | cd /mnt/lustre/ | ||
| + | |||
| + | mpirun -np $nproc -machinefile $PBS_NODEFILE | ||
| + | </file> | ||
| **Notes:** | **Notes:** | ||
| - | * Replace '' | + | * Replace '' |
| - | * Replace '' | + | * Replace '' |
| - | * And replace '' | + | * Replace '' |
| - | * And change '' | + | * And replace '' |
| + | * And change '' | ||
| + | |||
| + | ===Running the script=== | ||
| + | |||
| + | Submit to the scheduler | ||
| + | < | ||
| + | qsub my_R_job.qsub | ||
| + | </ | ||
| + | |||
| + | Check the list of current jobs in the queue | ||
| + | < | ||
| + | qstat -w | ||
| + | </ | ||
| + | |||
| + | ==== R/ | ||
| + | |||
| + | Here is a more complete example | ||
| + | |||
| + | === pbdR example === | ||
| + | == Job scripts == | ||
| + | <file bash pbdtest.qsub> | ||
| + | #PBS -l select=2: | ||
| + | #PBS -l walltime=00: | ||
| + | #PBS -q normal | ||
| + | #PBS -P SHORTNAME | ||
| + | #PBS -M YOUREMAILADDRESS | ||
| + | #PBS -m be | ||
| + | #PBS -e / | ||
| + | #PBS -o / | ||
| + | #PBS -N PBDR_TEST | ||
| + | #PBS -mb | ||
| + | |||
| + | module add chpc/ | ||
| + | |||
| + | NP=`cat ${PBS_NODEFILE} | wc -l` | ||
| + | |||
| + | cd / | ||
| + | mpirun -np ${NP} -machinefile ${PBS_NODEFILE} Rscript test_script.R | ||
| + | |||
| + | </ | ||
| + | Note: __USERNAME__ should contain your actual user name! | ||
| + | |||
| + | <file R test_script.R> | ||
| + | library(pbdMPI, | ||
| + | init() | ||
| + | my.rank <- comm.rank() | ||
| + | comm.print(my.rank, | ||
| + | |||
| + | finalize() | ||
| + | </ | ||
| + | |||
| + | == Submit your job == | ||
| + | Finally submit your job using:< | ||