This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
|
howto:r [2015/05/04 11:30] dane Updated for PBSPro |
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 ''/ |
| < | < | ||
| - | export MODULEPATH=/ | + | module add chpc/R/3.2.3-gcc5.1.0 |
| - | module add R/3.1.3 | + | |
| </ | </ | ||
| - | to your **'' | + | to your scripts |
| - | ==== Changes to .profile file ==== | ||
| - | On the CHPC clusters the '' | + | ===== Parallel R ===== |
| - | <code bash> | + | The '' |
| - | if [ -f ~/.bashrc ]; then | + | |
| - | | + | |
| - | fi | + | |
| - | </ | + | |
| - | Then make any changes to 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: | ||
| Line 32: | Line 19: | ||
| <file bash my_R_job.qsub> | <file bash my_R_job.qsub> | ||
| #!/bin/bash | #!/bin/bash | ||
| - | #PBS -l select=2: | + | #PBS -l select=2: |
| - | #PBS -l walltime=1: | + | #PBS -P SHORTNAME |
| - | #PBS -q workq | + | #PBS -q normal |
| - | #PBS -V | + | #PBS -l walltime=4: |
| - | #PBS -o /export/home/username/scratch5/ | + | #PBS -o /mnt/lustre/users/USERNAME/ |
| - | #PBS -e /export/home/username/scratch5/ | + | #PBS -e /mnt/lustre/users/USERNAME/ |
| #PBS -N RJob | #PBS -N RJob | ||
| #PBS -M myemailaddress@someplace.com | #PBS -M myemailaddress@someplace.com | ||
| #PBS -m abe | #PBS -m abe | ||
| - | # make sure appropriate R module is available | ||
| - | source / | ||
| - | MODULEPATH=/ | ||
| # Add R module (includes appropriate openMPI and gcc modules) | # Add R module (includes appropriate openMPI and gcc modules) | ||
| - | module add R/3.1.3 | + | module add chpc/R/3.2.3-gcc5.1.0 |
| # explicitly calculate number of processes. | # explicitly calculate number of processes. | ||
| Line 52: | Line 36: | ||
| # make sure we're in the correct working directory. | # make sure we're in the correct working directory. | ||
| - | cd /export/home/username/scratch5/my_R_data | + | cd /mnt/lustre/users/USERNAME/my_R_data |
| - | mpirun -np $nproc -machinefile $PBS_NODEFILE | + | mpirun -np $nproc -machinefile $PBS_NODEFILE |
| </ | </ | ||
| **Notes:** | **Notes:** | ||
| - | * Replace '' | + | * Replace '' |
| + | * Replace '' | ||
| * Replace '' | * Replace '' | ||
| - | * And replace '' | + | * And replace '' |
| * And change '' | * 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:< | ||
| + | |||