User Tools

Site Tools


environment_modules

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
environment_modules [2021/06/29 16:19]
root
environment_modules [2022/01/26 09:52] (current)
root
Line 1: Line 1:
 ===== Environment Modules ===== ===== Environment Modules =====
  
-**This page applies only to the new cluster.** +Environment modules allow you to control which software (and which version of that software) is available in your environment. For instance, at the time of writing, the cluster has 4 different version of standard R installed: 3.5.3, 3.6.3, 4.0.5, 4.1.0. When you first log in and try to run R the OS will respond with "command not found". To activate R in your environment you would type:
- +
-Environment modules allow you to control which software (and which version of that software) is available in your environment. For instance the new cluster has 4 different version of standard R installed: 3.5.3 +
-, 3.6.3, 4.0.5, 4.1.0. When you first log in and try to run R the OS will respond with "command not found". To activate R in your environment you would type:+
  
 <code> <code>
Line 30: Line 27:
 </code> </code>
  
-There's a shorthand version of the module command: **ml**. To load a module you can use just:+There's a shorthand version of the **module** command: **ml**. To load a module you can use just:
  
 <code> <code>
Line 61: Line 58:
 </code> </code>
  
-==== Where to Load Modules ====+ 
 +==== Where run Module Load Commands ====
  
 You have several options as to where to use "module load" commands. You have several options as to where to use "module load" commands.
Line 78: Line 76:
     * This might be a good way to specify what programs/modules are needed for specific pipelines that you commonly run.      * This might be a good way to specify what programs/modules are needed for specific pipelines that you commonly run. 
     * You could have your scripts source the list of programs needed for the pipeline rather than explicitly listing module load commands in each script.     * You could have your scripts source the list of programs needed for the pipeline rather than explicitly listing module load commands in each script.
 +
  
 ==== Module Conflicts ==== ==== Module Conflicts ====
Line 91: Line 90:
 This would generate an error because of the latest version of R already being loaded.  This would generate an error because of the latest version of R already being loaded. 
  
-So, in your script you should unload R before loading the new version.+So, in your script you could unload R before loading the new version.
  
 <code> <code>
Line 130: Line 129:
  
 In most cases, modules is just a nice easy way of updating you PATH. So it seems preferable to use the module command rather than updating your PATH explicitly. In most cases, modules is just a nice easy way of updating you PATH. So it seems preferable to use the module command rather than updating your PATH explicitly.
 +
  
 ==== Special Purpose Modules ==== ==== Special Purpose Modules ====
Line 139: Line 139:
     * This can lead to confusion if you have programs or scripts with the same name in different directories and forget where you are.     * This can lead to confusion if you have programs or scripts with the same name in different directories and forget where you are.
  
 +  * use.own
 +    * This module allows you to use modulefiles of your own. 
 +    * Try "module help use.own" for more information.
  
 +
 +==== Oddities and Exceptions ====
 +
 +=== Python and Perl ===
 +
 +Since various OS level tools need python and perl there are versions of these languages installed system-wide. No module needed. These are python3 (version 3.8.5) and perl (version 5.30.0). You are welcome to use these, but there are also modules with slightly different versions:
 +
 +  * python 2.7.18 for older software that requires python2
 +  * python 3.9.5
 +  * perl 5.34.0
 +
 +The system-wide python is accessible only as "python3". When a python module is loaded just "python" will start up the relevant version of python. 
 +
 +Python and perl packages that users request will be installed into the module versions of these programs. You can install python and perl packages locally as you wish (using any of these versions).
  
 More information about environment modules can be found here: https://modules.readthedocs.io/en/latest/ More information about environment modules can be found here: https://modules.readthedocs.io/en/latest/
 +
 +
 +=== Installing R Packages ===
 +
 +If you try to install an R package (as an ordinary user) and get a "permission denied" message like this:
 +
 +<code>
 +* installing to library '/opt/R/4.1.0/lib/R/library'
 +Error: ERROR: no permission to install to directory '/opt/R/4.1.0/lib/R/library'
 +</code>
 +
 +Then you might need to create the correct directory for R to use for package installation within your home directory. For R 4.1.0 this would be:
 +
 +~/R/x86_64-pc-linux-gnu-library/4.1
 +
 +Where "~" means "your home directory". You should only specify the first two parts of the full version number (hence the 4.1 for version 4.1.0).
 +
 +You can create the directory from the command line, like this:
 +
 +<code>
 +cd
 +mkdir -p ~/R/x86_64-pc-linux-gnu-library/4.1
 +</code>
 +
 +Or you can do it from within R, and then you won't need to know any details like the specific version number - the R program that you have started will fill them in for you:
 +
 +<code>
 +dir.create(Sys.getenv("R_LIBS_USER"), recursive = TRUE)
 +</code>
 +
 +=== Rscript and the "#!" Hack ===
 +
 +If you have used 
 +
 +<code>
 +#!/usr/bin/Rscript
 +</code>
 +
 +as the first line of your R scripts so that you can run them just like programs on the old cluster, they will no longer work on the new cluster. This is because there is no interpreter at /usr/bin/Rscript on the new cluster.
 +
 +On the new cluster you should load an R module (possibly from within your .bashrc file so that R is always available when you log in), and then use:
 +
 +<code>
 +#!/usr/bin/env Rscript
 +</code>
 +
 +at the top of your R scripts.
 +
  
environment_modules.1624997978.txt.gz · Last modified: 2021/06/29 16:19 by root