rsnt_translations
57,772
edits
No edit summary |
No edit summary |
||
Line 19: | Line 19: | ||
}} | }} | ||
<!--T: | <!--T:4--> | ||
You will also likely need to load gcc | You will also likely need to load gcc | ||
{{Command | {{Command | ||
Line 25: | Line 25: | ||
}} | }} | ||
<!--T: | <!--T:5--> | ||
You might also have to load various other modules depending on the packages you need to install. For example, "rgdal" will require that you load a module called "gdal", which itself requires that you load nixpkgs and gcc. Nixpkgs should already be loaded by default. You can ensure that it is by running | You might also have to load various other modules depending on the packages you need to install. For example, "rgdal" will require that you load a module called "gdal", which itself requires that you load nixpkgs and gcc. Nixpkgs should already be loaded by default. You can ensure that it is by running | ||
<!--T: | <!--T:6--> | ||
{{Command | {{Command | ||
|module list | |module list | ||
}} | }} | ||
<!--T: | <!--T:7--> | ||
If nixpkgs is not listed, you can load it by running | If nixpkgs is not listed, you can load it by running | ||
<!--T: | <!--T:8--> | ||
{{Command | {{Command | ||
|module load nixpkgs/16.09 | |module load nixpkgs/16.09 | ||
}} | }} | ||
<!--T: | <!--T:9--> | ||
If any package fails to install, be sure to read the error message carefully, as it might give you some details concerning some additional modules you need to load. You can also find out if a module is dependent on any other module by running | If any package fails to install, be sure to read the error message carefully, as it might give you some details concerning some additional modules you need to load. You can also find out if a module is dependent on any other module by running | ||
{{Command | {{Command | ||
Line 47: | Line 47: | ||
}} | }} | ||
<!--T: | <!--T:10--> | ||
With R and the appropriate modules now loaded in your environment, you can start the R interpreter and type R code inside that environment: | With R and the appropriate modules now loaded in your environment, you can start the R interpreter and type R code inside that environment: | ||
{{Command | {{Command | ||
Line 57: | Line 57: | ||
Platform: x86_64-pc-linux-gnu (64-bit) | Platform: x86_64-pc-linux-gnu (64-bit) | ||
<!--T: | <!--T:11--> | ||
R is free software and comes with ABSOLUTELY NO WARRANTY. | R is free software and comes with ABSOLUTELY NO WARRANTY. | ||
You are welcome to redistribute it under certain conditions. | You are welcome to redistribute it under certain conditions. | ||
Type 'license()' or 'licence()' for distribution details. | Type 'license()' or 'licence()' for distribution details. | ||
<!--T: | <!--T:12--> | ||
Natural language support but running in an English locale | Natural language support but running in an English locale | ||
<!--T: | <!--T:13--> | ||
R is a collaborative project with many contributors. | R is a collaborative project with many contributors. | ||
Type 'contributors()' for more information and | Type 'contributors()' for more information and | ||
'citation()' on how to cite R or R packages in publications. | 'citation()' on how to cite R or R packages in publications. | ||
<!--T: | <!--T:14--> | ||
Type 'demo()' for some demos, 'help()' for on-line help, or | Type 'demo()' for some demos, 'help()' for on-line help, or | ||
'help.start()' for an HTML browser interface to help. | 'help.start()' for an HTML browser interface to help. | ||
Type 'q()' to quit R. | Type 'q()' to quit R. | ||
<!--T: | <!--T:15--> | ||
> values <- c(3,5,7,9) | > values <- c(3,5,7,9) | ||
> values[0] | > values[0] | ||
Line 83: | Line 83: | ||
To execute R scripts, use the <tt>Rscript</tt> front-end with the file containing the R commands as an argument: | To execute R scripts, use the <tt>Rscript</tt> front-end with the file containing the R commands as an argument: | ||
<!--T: | <!--T:16--> | ||
{{Command|Rscript computation.R}} | {{Command|Rscript computation.R}} | ||
<!--T: | <!--T:17--> | ||
This front-end will automatically pass scripting-appropriate options <tt>--slave</tt> and <tt>--no-restore</tt> to the R interpreter. These also imply the <tt>--no-save</tt> option, preventing the creation of useless workspace files on exit. | This front-end will automatically pass scripting-appropriate options <tt>--slave</tt> and <tt>--no-restore</tt> to the R interpreter. These also imply the <tt>--no-save</tt> option, preventing the creation of useless workspace files on exit. | ||
== Installing R packages == <!--T: | == Installing R packages == <!--T:18--> | ||
To install packages from [https://cran.r-project.org/ CRAN], you can use the <tt>install.packages</tt> facility inside the R interpreter. Many R packages are developed using the Gnu family of compilers so we recommend that you load a <tt>gcc</tt> module before trying to install any R packages, using the same version of the <tt>gcc</tt> module for each package: | To install packages from [https://cran.r-project.org/ CRAN], you can use the <tt>install.packages</tt> facility inside the R interpreter. Many R packages are developed using the Gnu family of compilers so we recommend that you load a <tt>gcc</tt> module before trying to install any R packages, using the same version of the <tt>gcc</tt> module for each package: | ||
{{Command | {{Command | ||
Line 96: | Line 96: | ||
For example, to install the <tt>sp</tt> package that provides classes and methods for spatial data, use the following command on a login node: | For example, to install the <tt>sp</tt> package that provides classes and methods for spatial data, use the following command on a login node: | ||
<!--T: | <!--T:19--> | ||
{{Command | {{Command | ||
|R | |R | ||
Line 104: | Line 104: | ||
}} | }} | ||
<!--T: | <!--T:20--> | ||
When asked, select an appropriate mirror for download. Ideally, it will be geographically close to the cluster you're working on. | When asked, select an appropriate mirror for download. Ideally, it will be geographically close to the cluster you're working on. | ||
<!--T: | <!--T:21--> | ||
Some packages require defining the environment variable <tt>TMPDIR</tt> before installing and others expect the Gnu C and/or C++ compiler to be used rather than the Intel compiler family, so it is prudent to first load one of the <tt>gcc</tt> modules before starting R. | Some packages require defining the environment variable <tt>TMPDIR</tt> before installing and others expect the Gnu C and/or C++ compiler to be used rather than the Intel compiler family, so it is prudent to first load one of the <tt>gcc</tt> modules before starting R. | ||
<!--T: | <!--T:22--> | ||
To install a package that you downloaded (i.e. not from CRAN), you can install it as follow. Assuming the package is named <tt>archive_package.tgz</tt>, run the following command in a shell: | To install a package that you downloaded (i.e. not from CRAN), you can install it as follow. Assuming the package is named <tt>archive_package.tgz</tt>, run the following command in a shell: | ||
{{Command | {{Command | ||
Line 122: | Line 122: | ||
truly take advantage of the hardware. | truly take advantage of the hardware. | ||
=== Rmpi === <!--T: | === Rmpi === <!--T:23--> | ||
====Installing==== <!--T: | ====Installing==== <!--T:24--> | ||
This next procedure installs [https://cran.r-project.org/web/packages/Rmpi/index.html Rmpi], an interface (wrapper) to MPI routines, which allow R to run in parallel. | This next procedure installs [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: | <!--T:25--> | ||
1. See the available R modules by running: | 1. See the available R modules by running: | ||
<source lang="bash"> | <source lang="bash"> | ||
Line 133: | Line 133: | ||
</source> | </source> | ||
<!--T: | <!--T:26--> | ||
2. Select the version (here, for example, 3.4.0), and also load the required OpenMPI module: | 2. Select the version (here, for example, 3.4.0), and also load the required OpenMPI module: | ||
<source lang="bash"> | <source lang="bash"> | ||
Line 140: | Line 140: | ||
</source> | </source> | ||
<!--T: | <!--T:27--> | ||
3. Download [https://cran.r-project.org/web/packages/Rmpi/index.html the latest R version]; change the version number to whatever is desired. | 3. Download [https://cran.r-project.org/web/packages/Rmpi/index.html the latest R version]; change the version number to whatever is desired. | ||
<source lang="bash"> | <source lang="bash"> | ||
Line 146: | Line 146: | ||
</source> | </source> | ||
<!--T: | <!--T:28--> | ||
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"> | ||
Line 153: | Line 153: | ||
</source> | </source> | ||
<!--T: | <!--T:29--> | ||
5. Run the install command. | 5. Run the install command. | ||
<source lang="bash"> | <source lang="bash"> | ||
Line 159: | Line 159: | ||
</source> | </source> | ||
<!--T: | <!--T:30--> | ||
This uses OpenMPI version 1.10.7 which is needed to spawn processes correctly (the default MPI module 2.1.1 has a problem with that at present). | This uses OpenMPI version 1.10.7 which is needed to spawn processes correctly (the default MPI module 2.1.1 has a problem with that at present). | ||
Again, carefully read any error message that comes up when packages fail to install and load the required modules to ensure that all your packages are successfully installed. | Again, carefully read any error message that comes up when packages fail to install and load the required modules to ensure that all your packages are successfully installed. | ||
====Running==== <!--T: | ====Running==== <!--T:31--> | ||
<!--T: | <!--T:32--> | ||
1. Place your R code in a script file, in this case the file is called ''test.R''. | 1. Place your R code in a script file, in this case the file is called ''test.R''. | ||
<!--T: | <!--T:33--> | ||
{{File | {{File | ||
|name=test.R | |name=test.R | ||
Line 191: | Line 191: | ||
}} | }} | ||
<!--T: | <!--T:34--> | ||
2. Copy the following content in a job submission script called ''job.sh'': | 2. Copy the following content in a job submission script called ''job.sh'': | ||
<!--T: | <!--T:35--> | ||
{{File | {{File | ||
|name=job.sh | |name=job.sh | ||
Line 210: | Line 210: | ||
}} | }} | ||
<!--T: | <!--T:36--> | ||
3. Submit the job with: | 3. Submit the job with: | ||
<!--T: | <!--T:37--> | ||
<source lang="bash"> | <source lang="bash"> | ||
sbatch job.sh | sbatch job.sh | ||
</source> | </source> | ||
<!--T: | <!--T:38--> | ||
For more on submitting jobs, see the [[Running jobs]] page. | For more on submitting jobs, see the [[Running jobs]] page. | ||
=== doParallel and foreach === | === doParallel and foreach === | ||
<!--T: | <!--T:39--> | ||
====Usage==== | ====Usage==== | ||
Foreach can be considered as a unified interface for all backends (i.e. doMC, doMPI, doParallel, doRedis, etc.). It works on all platforms, assuming that the backend works. doParallel acts as an interface between foreach and the parallel package and can be loaded alone. There are some known efficiency issues when using foreach to run a very large number of very small tasks. Therefore, keep in mind that the following code is not the best example of an optimized use of the foreach() call but rather that the function chosen was kept at a minimum for demonstration purposes. | Foreach can be considered as a unified interface for all backends (i.e. doMC, doMPI, doParallel, doRedis, etc.). It works on all platforms, assuming that the backend works. doParallel acts as an interface between foreach and the parallel package and can be loaded alone. There are some known efficiency issues when using foreach to run a very large number of very small tasks. Therefore, keep in mind that the following code is not the best example of an optimized use of the foreach() call but rather that the function chosen was kept at a minimum for demonstration purposes. | ||
Line 232: | Line 232: | ||
# to register the backend; | # to register the backend; | ||
# to call foreach() by keeping it on the same line as the %do% (serial) or %dopar% operator. | # to call foreach() by keeping it on the same line as the %do% (serial) or %dopar% operator. | ||
<!--T: | <!--T:40--> | ||
====Running==== | ====Running==== | ||
1. Place your R code in a script file, in this case the file is called ''test_foreach.R''. | 1. Place your R code in a script file, in this case the file is called ''test_foreach.R''. | ||
<!--T: | <!--T:41--> | ||
{{File | {{File | ||
|name=test_foreach.R | |name=test_foreach.R | ||
Line 267: | Line 267: | ||
}} | }} | ||
<!--T: | <!--T:42--> | ||
2. Copy the following content in a job submission script called ''job_foreach.sh'': | 2. Copy the following content in a job submission script called ''job_foreach.sh'': | ||
<!--T: | <!--T:43--> | ||
{{File | {{File | ||
|name=job_foreach.sh | |name=job_foreach.sh | ||
Line 288: | Line 288: | ||
}} | }} | ||
<!--T: | <!--T:44--> | ||
3. Submit the job with: | 3. Submit the job with: | ||
<!--T: | <!--T:45--> | ||
<source lang="bash"> | <source lang="bash"> | ||
sbatch job_foreach.sh | sbatch job_foreach.sh | ||
</source> | </source> | ||
<!--T: | <!--T:46--> | ||
For more on submitting jobs, see the [[Running jobs]] page. | For more on submitting jobs, see the [[Running jobs]] page. | ||
</translate> | </translate> |