cc_staff
56
edits
(Marked this version for translation) |
(Removed the spaces before each line of code (for copy-pasting) and added 2 lines to the R script to get rid of error messages.) |
||
Line 90: | Line 90: | ||
1. See the available R modules by running: | 1. See the available R modules by running: | ||
<source lang="bash"> | <source lang="bash"> | ||
module spider r | |||
</source> | </source> | ||
Line 96: | Line 96: | ||
2. Select the version (here, we indicate the latest Novembre 2017 version), and also load the required OpenMPI module: | 2. Select the version (here, we indicate the latest Novembre 2017 version), and also load the required OpenMPI module: | ||
<source lang="bash"> | <source lang="bash"> | ||
module load r/3.4.0 | |||
module load openmpi/1.10.7 | |||
</source> | </source> | ||
Line 109: | Line 109: | ||
4. Specify the directory where you want to install the package files; you must have write permission for this directory. The directory name can be changed if desired. | 4. Specify the directory where you want to install the package files; you must have write permission for this directory. The directory name can be changed if desired. | ||
<source lang="bash"> | <source lang="bash"> | ||
mkdir -p ~/local/R_libs/ | |||
export R_LIBS=~/local/R_libs/ | |||
</source> | </source> | ||
Line 129: | Line 129: | ||
<!--T:32--> | <!--T:32--> | ||
<source lang="r"> | <source lang="r"> | ||
#Tell all slaves to return a message identifying themselves. | |||
library("Rmpi") | |||
sprintf("TEST mpi.universe.size() = %i", mpi.universe.size()) | |||
ns <- mpi.universe.size() - 1 | |||
sprintf("TEST attempt to spawn %i slaves", ns) | |||
mpi.spawn.Rslaves(nslaves=ns) | |||
mpi.remote.exec(paste("I am",mpi.comm.rank(),"of",mpi.comm.size())) | |||
mpi.remote.exec(paste(mpi.comm.get.parent())) | |||
#Send execution commands to the slaves | |||
x<-5 | |||
#These would all be pretty correlated one would think | |||
x<-mpi.remote.exec(rnorm,x) | |||
length(x) | |||
x | |||
mpi.close.Rslaves() | |||
mpi.quit() | |||
</source> | </source> | ||
Line 150: | Line 152: | ||
<!--T:34--> | <!--T:34--> | ||
<source lang="bash"> | <source lang="bash"> | ||
#!/bin/bash | |||
#SBATCH --account=def-ppomorsk # replace this with your own account | |||
#SBATCH --ntasks=5 # number of MPI processes | |||
#SBATCH --mem-per-cpu=2048M # memory; default unit is megabytes | |||
#SBATCH --time=0-00:15 # time (DD-HH:MM) | |||
module load r/3.4.0 | |||
module load openmpi/1.10.7 | |||
export R_LIBS=~/local/R_libs/ | |||
mpirun -np 1 R CMD BATCH test.R test.txt | |||
</source> | </source> | ||
Line 166: | Line 168: | ||
<!--T:36--> | <!--T:36--> | ||
<source lang="bash"> | <source lang="bash"> | ||
sbatch job.sh | |||
</source> | </source> | ||