Difference between revisions of "Installing your own modules"

From IBERS Bioinformatics and HPC Wiki
Jump to: navigation, search
Line 3: Line 3:
  
 
'''These are some key commands:'''
 
'''These are some key commands:'''
 +
 
<code>module avail</code> - lists the modules available
 
<code>module avail</code> - lists the modules available
 +
 
<code>module list</code> - lists the modules currently loaded  
 
<code>module list</code> - lists the modules currently loaded  
 +
 
<code>module load <module name></code>  - loads named module  
 
<code>module load <module name></code>  - loads named module  
<code>module unload <module name></code>  - unloads named module
 
  
 +
<code>module unload <module name></code>  - unloads named module
 +
 
To set up a module, you need two things - first the executables which are generally placed in one directory called apps, but really could be anywhere as long as you know where they are. The second is a modulefile, which are kept together in one location called modulefiles. The path to the module files then is added to your <code>$MODULEPATH</code>, which can be done in the <code>.bashrc</code> file.  
 
To set up a module, you need two things - first the executables which are generally placed in one directory called apps, but really could be anywhere as long as you know where they are. The second is a modulefile, which are kept together in one location called modulefiles. The path to the module files then is added to your <code>$MODULEPATH</code>, which can be done in the <code>.bashrc</code> file.  
'''
+
 
1. Install the program:'''
+
'''1. Install the program:'''
 +
 
 
Download and install the program according to instructions provided in its own appropriately named directory. This would best be done in a directory called apps, which can be placed somewhere sensible such as your home directory or in a shared directory if the modules are to be group accessible. Any already installed programs can be copied into apps, but note that some programs make have to be recompiled if certain paths have to be specified for it to function properly. These may require reinstalling from source.  
 
Download and install the program according to instructions provided in its own appropriately named directory. This would best be done in a directory called apps, which can be placed somewhere sensible such as your home directory or in a shared directory if the modules are to be group accessible. Any already installed programs can be copied into apps, but note that some programs make have to be recompiled if certain paths have to be specified for it to function properly. These may require reinstalling from source.  
 +
 
'''2. Make the modulefile'''
 
'''2. Make the modulefile'''
 +
 
All of the modulefiles are kept in the modulefiles directory, which can either be local to you or in a shared directory if other people are to load modules. If you plan on installing multiple versions of the same program it is good to create a directory named after the program, then have one modulefile for each version in that directory.
 
All of the modulefiles are kept in the modulefiles directory, which can either be local to you or in a shared directory if other people are to load modules. If you plan on installing multiple versions of the same program it is good to create a directory named after the program, then have one modulefile for each version in that directory.
 
Then make the following modulefile, changing the <text> as necessary (If other modules are required, load them here too, otherwise this part can be removed).
 
Then make the following modulefile, changing the <text> as necessary (If other modules are required, load them here too, otherwise this part can be removed).
<code>
+
 
#%Module -*- tcl -*-
+
<nowiki>#%Module -*- tcl -*-
 
##
 
##
 
## modulefile
 
## modulefile
 
##
 
##
 
proc ModulesHelp { } {
 
proc ModulesHelp { } {
 
 
     puts stderr "\t<Text about the program>."  
 
     puts stderr "\t<Text about the program>."  
 
}
 
}
Line 27: Line 33:
 
<module load <pre-requisite module>>
 
<module load <pre-requisite module>>
  
module-whatis "<Text about the program>"  
+
module-whatis "<Text about the program>"
 +
 
 +
prepend-path      PATH              /path/to/apps/program</nowiki>
  
prepend-path     PATH              /path/to/apps/program
+
'''3. Append modulefile path to $MODULEPATH (one time occurrence):'''
</code>
 
  
3.) Append modulefile path to $MODULEPATH (one time occurrence):
 
 
You will now need to append the path to the module files to your <code>$MODULEPATH</code> variable, which tells the module command where to look for modulefiles, which in turn say where to look for the executables. One way to do this is in your <code>.bashrc</code> file in your home directory, add this line:  
 
You will now need to append the path to the module files to your <code>$MODULEPATH</code> variable, which tells the module command where to look for modulefiles, which in turn say where to look for the executables. One way to do this is in your <code>.bashrc</code> file in your home directory, add this line:  
<code>
+
 
#add local modules to module path:
+
<nowiki>#add local modules to module path:
export MODULEPATH="$MODULEPATH:/path/to/modulefiles"
+
export MODULEPATH="$MODULEPATH:/path/to/modulefiles" </nowiki>
</code>
+
 
 
Then do source <code>.bashrc</code> to activate this.  
 
Then do source <code>.bashrc</code> to activate this.  
 +
 
Repeat this for anyone in the group who wants to be able to load these modules.
 
Repeat this for anyone in the group who wants to be able to load these modules.
  
 
Now when you type module avail, the program(s) you have installed should be listed under the dashed section with the header that matches your modulefiles path. To load a module, use module load and to unload use module unload.
 
Now when you type module avail, the program(s) you have installed should be listed under the dashed section with the header that matches your modulefiles path. To load a module, use module load and to unload use module unload.

Revision as of 12:26, 7 October 2021

A module is essentially a way of controlling which programs or tools are loaded in your environment at any one time, allowing for version control. The IBERS HPC has some universally available modules to load, and polite requests to admins can see new modules added to this. However this can take time and effort, so an alternative is to make modules available for just yourself or for a group.

These are some key commands:

module avail - lists the modules available

module list - lists the modules currently loaded

module load <module name> - loads named module

module unload <module name> - unloads named module

To set up a module, you need two things - first the executables which are generally placed in one directory called apps, but really could be anywhere as long as you know where they are. The second is a modulefile, which are kept together in one location called modulefiles. The path to the module files then is added to your $MODULEPATH, which can be done in the .bashrc file.

1. Install the program:

Download and install the program according to instructions provided in its own appropriately named directory. This would best be done in a directory called apps, which can be placed somewhere sensible such as your home directory or in a shared directory if the modules are to be group accessible. Any already installed programs can be copied into apps, but note that some programs make have to be recompiled if certain paths have to be specified for it to function properly. These may require reinstalling from source.

2. Make the modulefile

All of the modulefiles are kept in the modulefiles directory, which can either be local to you or in a shared directory if other people are to load modules. If you plan on installing multiple versions of the same program it is good to create a directory named after the program, then have one modulefile for each version in that directory. Then make the following modulefile, changing the <text> as necessary (If other modules are required, load them here too, otherwise this part can be removed).

#%Module -*- tcl -*-
##
## modulefile
##
proc ModulesHelp { } {
    puts stderr "\t<Text about the program>." 
}

<module load <pre-requisite module>>

module-whatis "<Text about the program>"

prepend-path      PATH              /path/to/apps/program

3. Append modulefile path to $MODULEPATH (one time occurrence):

You will now need to append the path to the module files to your $MODULEPATH variable, which tells the module command where to look for modulefiles, which in turn say where to look for the executables. One way to do this is in your .bashrc file in your home directory, add this line:

#add local modules to module path:
export MODULEPATH="$MODULEPATH:/path/to/modulefiles" 

Then do source .bashrc to activate this.

Repeat this for anyone in the group who wants to be able to load these modules.

Now when you type module avail, the program(s) you have installed should be listed under the dashed section with the header that matches your modulefiles path. To load a module, use module load and to unload use module unload.