load these modules (put them in ~/.my.bash_profile)
module load slurm
module load R/r-3.1.1
module load proj/proj-4.8.0_gcc-4.9.2
module load gdal/gdal-1.11.2_hdf5-1.8.14_netcdf4-4.4.2_gcc-4.9.2
module load zlib/zlib-1.2.7
in R
install.packages('rgdal',configure.args="--with-gdal-config=`which gdal-config` --with-proj-include=/curc/tools/x_86_64/rh6/proj/4.8.0/gcc/4.9.2/include --with-proj-lib=/curc/tools/x_86_64/rh6/proj/4.8.0/gcc/4.9.2/lib")
install.packages('ncdf4',configure.args="--with-nc-config=/curc/tools/x_86_64/rh6/netcdf4/4.4.2/gcc/4.9.2/bin/nc-config")
Download Rmpi
wget http://cran.r-project.org/src/contrib/Rmpi_0.6-5.tar.gz
Install Rmpi
export MPIHOME=`echo $OMPIDIR`
R CMD INSTALL --configure-vars="CPPFLAGS=-I$MPIHOME/include LDFLAGS='-L$MPIHOME/lib'" --configure-args="--with-Rmpi-include=$MPIHOME/include --with-Rmpi-libpath=$MPIHOME/lib --with-Rmpi-type=OPENMPI" Rmpi_0.6-5.tar.gz
test it in R, you shouldn't get any error messages
library(parallel)
cl = makeCluster(8, type='MPI')
Test job (save as job.sh)
#!/bin/bash
## job.sh example testing Rmpi
## you should see output that has 2 different node names
# Set the name of the job
#SBATCH -J get_cluster_names
# Set a walltime for the job. The time format is HH:MM:SS
#SBATCH --time=00:00:30
# Select nodes
#SBATCH -N 2
# Select one task per node (similar to one processor per node)
#SBATCH --ntasks-per-node 10
# Set output file name with job number
#SBATCH -o output-testjob-%j.out
# Use the normal QOS
#SBATCH --qos=janus-debug
#SBATCH --mail-type=ALL #Type of email notification- BEGIN,END,FAIL,ALL
#SBATCH --mail-user=cameron.bracken@colorado.edu #Email to which notifications will be sent
nodes=2
ppn=10
np=$(($nodes*$ppn))
# Get OpenMPI in our PATH.
module load R/r-3.1.1
`which mpirun` -n 1 `which R` --vanilla --slave <<EOF
library(parallel)
cl <- makeCluster($np,type="MPI")
clusterCall(cl, function() Sys.info()[c("nodename","machine")])
clusterCall(cl, runif, $np)
stopCluster(cl)
mpi.quit()
EOF
Run the job
sbatch job.sh
This is what the output should look like
[bracken@janus-compile2 testing]$ cat output-testjob-574967.out
Loading required package: Rmpi
20 slaves are spawned successfully. 0 failed.
[[1]]
nodename machine
"node0746" "x86_64"
[[2]]
nodename machine
"node0746" "x86_64"
[[3]]
nodename machine
"node0746" "x86_64"
[[4]]
nodename machine
"node0746" "x86_64"
[[5]]
nodename machine
"node0746" "x86_64"
[[6]]
nodename machine
"node0746" "x86_64"
[[7]]
nodename machine
"node0746" "x86_64"
[[8]]
nodename machine
"node0746" "x86_64"
[[9]]
nodename machine
"node0746" "x86_64"
[[10]]
nodename machine
"node0747" "x86_64"
[[11]]
nodename machine
"node0747" "x86_64"
[[12]]
nodename machine
"node0747" "x86_64"
[[13]]
nodename machine
"node0747" "x86_64"
[[14]]
nodename machine
"node0747" "x86_64"
[[15]]
nodename machine
"node0747" "x86_64"
[[16]]
nodename machine
"node0747" "x86_64"
[[17]]
nodename machine
"node0747" "x86_64"
[[18]]
nodename machine
"node0747" "x86_64"
[[19]]
nodename machine
"node0747" "x86_64"
[[20]]
nodename machine
"node0746" "x86_64"
[[1]]
[1] 0.97694698 0.22260736 0.89455426 0.07187533 0.17165465 0.19238875
[7] 0.87554978 0.76573882 0.08829578 0.52840944 0.78387779 0.95251332
[13] 0.53208505 0.12299317 0.24665796 0.85943604 0.08171168 0.59359189
[19] 0.24409226 0.10031408
[[2]]
[1] 0.7724078030 0.0008525935 0.2476931864 0.7522173042 0.3323636637
[6] 0.0904417913 0.7003499190 0.5195561564 0.9768140621 0.6911092352
[11] 0.4056184327 0.4163204455 0.8430902995 0.9674736236 0.9370399290
[16] 0.7415919823 0.6977432221 0.1934447077 0.9279429337 0.1203879211
[[3]]
[1] 0.86574514 0.27450880 0.66870146 0.93762337 0.91774352 0.55917676
[7] 0.39741678 0.80385492 0.26091614 0.68301369 0.15153283 0.84313420
[13] 0.82627420 0.19049149 0.60083237 0.57124644 0.38703754 0.11068753
[19] 0.38332880 0.08063709
[[4]]
[1] 0.82227033 0.49118378 0.67180412 0.86271237 0.77266984 0.92615070
[7] 0.07448874 0.40747150 0.39738863 0.13716564 0.85378753 0.55476001
[13] 0.50443839 0.14356231 0.09909449 0.14906432 0.57881970 0.20606314
[19] 0.17779536 0.80322816
[[5]]
[1] 0.07052103 0.44139729 0.58111032 0.43753849 0.42910040 0.34154314
[7] 0.34918383 0.06123153 0.94774087 0.87744931 0.96505388 0.37677417
[13] 0.52845997 0.61625821 0.21443237 0.40610787 0.56504383 0.43548994
[19] 0.28834937 0.44937336
[[6]]
[1] 0.692056982 0.417407896 0.636674002 0.715428869 0.155244254 0.805505219
[7] 0.023342349 0.583438738 0.446566538 0.546385115 0.452208473 0.790432306
[13] 0.007600622 0.329342789 0.937212227 0.419438698 0.423629443 0.097819147
[19] 0.031460112 0.382750568
[[7]]
[1] 0.6398631 0.3515324 0.3173927 0.7217511 0.6218931 0.1249589 0.3335470
[8] 0.5468134 0.4807176 0.2205171 0.5598691 0.5548576 0.8777898 0.3886650
[15] 0.9928074 0.1253199 0.9318856 0.2625252 0.8938159 0.7462889
[[8]]
[1] 0.07001306 0.48822647 0.08756431 0.94263972 0.43446751 0.02171343
[7] 0.78940388 0.72581396 0.92010499 0.05257820 0.06827108 0.97120513
[13] 0.83295449 0.45935299 0.46539741 0.60730163 0.27044952 0.34786105
[19] 0.92879232 0.71314407
[[9]]
[1] 0.31444367 0.10134114 0.07322751 0.49485434 0.70638809 0.97307017
[7] 0.14323231 0.34798408 0.04612173 0.08831643 0.72130562 0.05809863
[13] 0.86090777 0.93745602 0.97578600 0.14792786 0.06511505 0.29831033
[19] 0.84694453 0.98588533
[[10]]
[1] 0.01217255 0.54759617 0.17483414 0.48199459 0.17052783 0.46636653
[7] 0.33572072 0.04088788 0.52934321 0.60655192 0.68683157 0.86200439
[13] 0.11921854 0.11779370 0.03985551 0.13340570 0.35156032 0.96917855
[19] 0.36781519 0.44548134
[[11]]
[1] 0.31519193 0.86019009 0.36668315 0.30090985 0.75864949 0.43857908
[7] 0.59555908 0.79669148 0.83563344 0.47359889 0.61397153 0.86414582
[13] 0.70854023 0.88642975 0.10422679 0.46260959 0.09852302 0.13194173
[19] 0.76538785 0.41405521
[[12]]
[1] 0.30263062 0.08798864 0.56655664 0.11775236 0.87087001 0.83982553
[7] 0.74446130 0.73125924 0.11379407 0.69026796 0.00183065 0.43600481
[13] 0.79226049 0.24388449 0.28516199 0.41949473 0.03201803 0.78631787
[19] 0.77430956 0.80905239
[[13]]
[1] 0.86937963 0.82632492 0.06376998 0.51776250 0.45322541 0.42149406
[7] 0.65281860 0.44779957 0.09298178 0.05893831 0.69498862 0.46586887
[13] 0.72871278 0.31237774 0.03963645 0.20620677 0.60451628 0.82192187
[19] 0.23732789 0.45131788
[[14]]
[1] 0.22613204 0.01488751 0.16463257 0.72213915 0.83544309 0.69722851
[7] 0.97120319 0.25009666 0.51751831 0.45657150 0.23631591 0.55691746
[13] 0.58904566 0.98772293 0.45314167 0.41962539 0.59760155 0.51801186
[19] 0.48007809 0.62231282
[[15]]
[1] 0.508279939 0.387826825 0.612379055 0.283685990 0.822948487 0.254180425
[7] 0.252647152 0.210353358 0.835778134 0.276504662 0.146441979 0.001939200
[13] 0.393221691 0.595140962 0.004091688 0.722075846 0.866895135 0.965661800
[19] 0.122564383 0.719660439
[[16]]
[1] 0.8695933 0.2702814 0.3875578 0.7466010 0.5949634 0.6392646 0.6075044
[8] 0.2274109 0.3068769 0.1639696 0.1018778 0.2105149 0.5660303 0.3499232
[15] 0.4602891 0.8909680 0.4496966 0.8110817 0.2926470 0.1882644
[[17]]
[1] 0.97864744 0.06891319 0.51135491 0.40306670 0.38726713 0.70410543
[7] 0.78381356 0.52534653 0.93819438 0.79506471 0.21529320 0.24020953
[13] 0.59857377 0.73101253 0.80720021 0.55746751 0.91402530 0.37517384
[19] 0.19783825 0.40431262
[[18]]
[1] 0.08601411 0.86198693 0.03723611 0.14104563 0.11362102 0.89468639
[7] 0.97356919 0.74290697 0.59029149 0.11225282 0.10591472 0.46948783
[13] 0.90708003 0.25947399 0.61642248 0.77813792 0.48154562 0.68215865
[19] 0.52621360 0.86280893
[[19]]
[1] 0.01481683 0.17665607 0.38112056 0.47576847 0.85348592 0.29672971
[7] 0.86205005 0.56354701 0.81439067 0.83089602 0.54780840 0.02837781
[13] 0.78589269 0.89260461 0.26047056 0.32179545 0.55466389 0.12180827
[19] 0.70097727 0.26207932
[[20]]
[1] 0.3130162 0.8694904 0.5730996 0.7467951 0.9498100 0.5711970 0.7893234
[8] 0.7347778 0.1137956 0.6545252 0.1571039 0.5863210 0.2579049 0.9739693
[15] 0.7498182 0.4258484 0.7515562 0.9086401 0.4747172 0.8117647
[1] 1