rsnt_translations
58,180
edits
(→Running: include R script) |
(Marked this version for translation) |
||
Line 84: | Line 84: | ||
=== Rmpi === <!--T:16--> | === Rmpi === <!--T:16--> | ||
====Installing==== | ====Installing==== <!--T:18--> | ||
Below is the procedure to install [https://cran.r-project.org/web/packages/Rmpi/index.html Rmpi], an interface (wrapper) to MPI routines, which allow R to run in parallel. | Below is the procedure to install [https://cran.r-project.org/web/packages/Rmpi/index.html Rmpi], an interface (wrapper) to MPI routines, which allow R to run in parallel. | ||
<!--T:19--> | |||
First, load the R module. You can find out which are available by running: | First, load the R module. You can find out which are available by running: | ||
module spider r | <!--T:20--> | ||
module spider r | |||
<!--T:21--> | |||
In this case we choose the latest (as of November, 2017): | In this case we choose the latest (as of November, 2017): | ||
module load r/3.4.0 | <!--T:22--> | ||
module load r/3.4.0 | |||
<!--T:23--> | |||
Next, download the latest version of the software from [https://cran.r-project.org/web/packages/Rmpi/index.html]. Change the version number to whatever is desired. | Next, download the latest version of the software from [https://cran.r-project.org/web/packages/Rmpi/index.html]. Change the version number to whatever is desired. | ||
wget https://cran.r-project.org/src/contrib/Rmpi_0.6-6.tar.gz | <!--T:24--> | ||
wget https://cran.r-project.org/src/contrib/Rmpi_0.6-6.tar.gz | |||
<!--T:25--> | |||
Then specify the directory to install the package files in a directory you can write to. The name can be changed as desired. | Then specify the directory to install the package files in a directory you can write to. The name can be changed as desired. | ||
mkdir -p ~/local/R_libs/ | <!--T:26--> | ||
mkdir -p ~/local/R_libs/ | |||
export R_LIBS=~/local/R_libs/ | export R_LIBS=~/local/R_libs/ | ||
<!--T:27--> | |||
Finally, run the install command. | Finally, run the install command. | ||
<!--T:28--> | |||
<source lang="bash"> | <source lang="bash"> | ||
R CMD INSTALL --configure-args="--with-Rmpi-include=$EBROOTOPENMPI/include --with-Rmpi-libpath=$EBROOTOPENMPI/lib --with-Rmpi-type='OPENMPI' " Rmpi_0.6-6.tar.gz | R CMD INSTALL --configure-args="--with-Rmpi-include=$EBROOTOPENMPI/include --with-Rmpi-libpath=$EBROOTOPENMPI/lib --with-Rmpi-type='OPENMPI' " Rmpi_0.6-6.tar.gz | ||
</source> | </source> | ||
<!--T:29--> | |||
This will use the default version of MPI to perform the install, which is currently 2.1.1. | This will use the default version of MPI to perform the install, which is currently 2.1.1. | ||
====Running==== | ====Running==== <!--T:30--> | ||
<!--T:31--> | |||
Please your R code in a script file, in this case test.R. | Please your R code in a script file, in this case test.R. | ||
#Tell all slaves to return a message identifying themselves. | <!--T:32--> | ||
#Tell all slaves to return a message identifying themselves. | |||
library("Rmpi") | library("Rmpi") | ||
sprintf("TEST mpi.universe.size() = %i", mpi.universe.size()) | sprintf("TEST mpi.universe.size() = %i", mpi.universe.size()) | ||
Line 133: | Line 146: | ||
x | x | ||
<!--T:33--> | |||
Then place the following in a job submission script, job.sh : | Then place the following in a job submission script, job.sh : | ||
#!/bin/bash | <!--T:34--> | ||
#!/bin/bash | |||
#SBATCH --account=def-ppomorsk # replace this with your own account | #SBATCH --account=def-ppomorsk # replace this with your own account | ||
#SBATCH --ntasks=5 # number of MPI processes | #SBATCH --ntasks=5 # number of MPI processes | ||
Line 144: | Line 159: | ||
mpirun -np 1 R CMD BATCH test.R test.txt | mpirun -np 1 R CMD BATCH test.R test.txt | ||
<!--T:35--> | |||
Finally, submit the job with: | Finally, submit the job with: | ||
sbatch job.sh | <!--T:36--> | ||
sbatch job.sh | |||
<!--T:37--> | |||
For more on submitting jobs, see the [[Running jobs]] page. | For more on submitting jobs, see the [[Running jobs]] page. | ||
</translate> | </translate> |