Newer
Older
# EasyBuild
The objective of this tutorial is to show how EasyBuild can be used to ease, automate, and script the build of software on the IT4Innovations clusters. Two use-cases are considered. First, we are going to build a software that is supported by EasyBuild. Then, we will see through a simple example how to add support for a new software in EasyBuild.
The benefit of using EasyBuild for your builds is that it allows automated and reproducible build of software. Once a build has been made, the build script (via the EasyConfig file) or the installed software (via the module file) can be shared with other users.
## Short Introduction
EasyBuild is a tool that allows performing automated and reproducible software compilation and installation.
All builds and installations are performed at user level, so you do not need the admin rights. The software is installed in your home directory (by default in `$HOME/.local/easybuild/software/`) and a module file is generated (by default in `$HOME/.local/easybuild/modules/`) to use the software.
EasyBuild relies on two main concepts:
* Toolchains
* EasyConfig file (our easyconfigs are [here][a])
A detailed documentation is available [here][b].
## Toolchains
A toolchain corresponds to a compiler and a set of libraries, which are commonly used to build a software. The two main toolchains frequently used on the IT4Innovations clusters are the **foss** and **intel**.
* **foss** is based on the GCC compiler and on open-source libraries (OpenMPI, OpenBLAS, etc.).
* **intel** is based on the Intel compiler and on Intel libraries (Intel MPI, Intel Math Kernel Library, etc.).
Additional details are available [here][c].
## EasyConfig File
The EasyConfig file is a simple text file that describes the build process of a software. For most software that uses standard procedure (like configure, make, and make install), this file is very simple. Many EasyConfig files are already provided with EasyBuild.
By default, EasyConfig files and generated modules are named using the following convention:
`software-name-software-version-toolchain-name-toolchain-version(-suffix).eb`
Additional details are available [here][d].
## EasyBuild on IT4Innovations Clusters
To use EasyBuild on a compute node, load the `EasyBuild` module:
```console
------------------------------------------ /apps/modules/tools -------------------------------------------
EasyBuild/4.3.3 (S) EasyBuild/4.4.2 (S) EasyBuild/4.5.4 (S) EasyBuild/4.6.2 (S)
EasyBuild/4.3.4 (S) EasyBuild/4.5.0 (S) EasyBuild/4.5.5 (S) EasyBuild/4.7.0 (S,D)
EasyBuild/4.4.0 (S) EasyBuild/4.5.1 (S) EasyBuild/4.6.0 (S)
EasyBuild/4.4.1 (S) EasyBuild/4.5.3 (S) EasyBuild/4.6.1 (S)
Where:
S: Module is Sticky, requires --force to unload or purge
D: Default Module
Use "module spider" to find all possible modules and extensions.
Use "module keyword key1 key2 ..." to search for all possible modules matching any of the "keys".
$ ml EasyBuild
```
The EasyBuild command is `eb`. Check the version you have loaded:
```console
$ eb --version
This is EasyBuild 4.7.0 (framework: 4.7.0, easyblocks: 4.7.0) on host login1.karolina.it4i.cz.
```
To get help on the EasyBuild options, use the `-h` or `-H` option flags:
```console
$ eb -h
Usage: eb [options] easyconfig [...]
Builds software based on easyconfig (or parse a directory). Provide one or more easyconfigs or
directories, use -H or --help more information.
Options:
-h show short help message and exit
-H OUTPUT_FORMAT show full help message and exit
Debug and logging options (configfile section MAIN):
-d Enable debug log mode (default: False)
Basic options:
Basic runtime options for EasyBuild. (configfile section basic)
...
```
## Build Software Using Provided EasyConfig File
### Search for Available Easyconfig
Searching for available easyconfig files can be done using the `--search` (long output) and `-S` (short output) command line options. All easyconfig files available in the robot search path are considered and searching is done case-insensitive.
```console
$ eb -S git
CFGS1=/apps/easybuild/easyconfigs-it4i
CFGS2=/apps/easybuild/easyconfigs-master/easybuild/easyconfigs
CFGS3=/apps/easybuild/easyconfigs-develop/easybuild/easyconfigs
* $CFGS1/.gitignore
* $CFGS1/.gitlab-ci.yml
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
* $CFGS1/g/git-lfs/git-lfs-2.11.0.eb
* $CFGS1/g/git-lfs/git-lfs-3.1.2.eb
* $CFGS1/g/git/git-2.19.1.eb
* $CFGS1/g/git/git-2.21.0.eb
* $CFGS1/g/git/git-2.23.0.eb
* $CFGS1/g/git/git-2.25.1.eb
* $CFGS1/g/git/git-2.30.1.eb
* $CFGS1/g/git/git-2.31.1.eb
* $CFGS1/g/git/git-2.32.0-GCCcore-10.3.0-nodocs-test.eb
* $CFGS2/b/BCALM/BCALM-2.2.0-fix-nogit.patch
* $CFGS2/d/dagitty/dagitty-0.2-2-foss-2018b-R-3.5.1.eb
* $CFGS2/e/EMAN2/EMAN2-2.3_fix_broken_githash_regex_replace.patch
* $CFGS2/g/GIMIC/GIMIC-2018.04.20_git.patch
* $CFGS2/g/GitPython/GitPython-2.1.11-foss-2018b-Python-3.6.6.eb
* $CFGS2/g/GitPython/GitPython-2.1.11-intel-2018b-Python-3.6.6.eb
* $CFGS2/g/GitPython/GitPython-2.1.15.eb
* $CFGS2/g/GitPython/GitPython-3.0.3-GCCcore-8.2.0-Python-3.7.2.eb
* $CFGS2/g/GitPython/GitPython-3.1.0-GCCcore-8.3.0-Python-3.7.4.eb
* $CFGS2/g/GitPython/GitPython-3.1.9-GCCcore-9.3.0-Python-3.8.2.eb
* $CFGS2/g/GitPython/GitPython-3.1.14-GCCcore-10.2.0.eb
* $CFGS2/g/GitPython/GitPython-3.1.18-GCCcore-10.3.0.eb
* $CFGS2/g/GitPython/GitPython-3.1.24-GCCcore-11.2.0.eb
* $CFGS2/g/GitPython/GitPython-3.1.27-GCCcore-11.3.0.eb
* $CFGS2/g/gettext/gettext-0.19.8_fix-git-config.patch
* $CFGS2/g/git-extras/git-extras-5.1.0-foss-2016a.eb
...
```
### Get an Overview of Planned Installations
You can do a “dry-run” overview by supplying `-D`/`--dry-run` (typically combined with `--robot`, in the form of `-Dr`):
```console
$ eb git-2.30.1.eb -Dr
== Temporary log file in case of crash /tmp/eb-6vwvor2_/easybuild-vg82aat4.log
Dry run: printing build status of easyconfigs and dependencies
CFGS=/apps/easybuild
* [x] $CFGS/easyconfigs-master/easybuild/easyconfigs/m/M4/M4-1.4.18.eb (module: M4/1.4.18)
* [x] $CFGS/easyconfigs-it4i/a/Autoconf/Autoconf-2.69.eb (module: Autoconf/2.69)
* [ ] $CFGS/easyconfigs-it4i/g/git/git-2.30.1.eb (module: git/2.30.1)
== Temporary log file(s) /tmp/eb-6vwvor2_/easybuild-vg82aat4.log* have been removed.
== Temporary directory /tmp/eb-6vwvor2_ has been removed.
If we try to build *git-2.31.1.eb*, nothing will happen as it is already installed on the cluster. To enable dependency resolution, use the `--robot` command line option (or `-r` for short):
$ eb git-2.31.1.eb -r
== Temporary log file in case of crash /tmp/eb-11d_kpht/easybuild-jmygqpqr.log
== git/2.31.1 is already installed (module found), skipping
== Temporary log file(s) /tmp/eb-11d_kpht/easybuild-jmygqpqr.log* have been removed.
== Temporary directory /tmp/eb-11d_kpht has been removed.
Rebuild *git-2.31.1.eb*. Use `eb --rebuild` to rebuild a given easyconfig/module or use `eb --force`/`-f` to force the reinstallation of a given easyconfig/module. The behavior of `--force` is the same as `--rebuild` and `--ignore-osdeps`.
$ eb git-2.31.1.eb -r -f
== Temporary log file in case of crash /tmp/eb-wbzf_rxh/easybuild-umq1_01u.log
== processing EasyBuild easyconfig /apps/easybuild/easyconfigs-it4i/g/git/git-2.31.1.eb
== building and installing git/2.31.1...
== fetching files...
== creating build dir, resetting environment...
== postprocessing...
== sanity checking...
== cleaning up...
== creating module...
== permissions...
== packaging...
== COMPLETED: Installation ended successfully (took 30 secs)
== Results of the build can be found in the log file(s)
/home/username/.local/easybuild/software/git/2.31.1/easybuild/easybuild-git-2.31.1-20230315.092001.log
== Temporary log file(s) /tmp/eb-wbzf_rxh/easybuild-umq1_01u.log* have been removed.
== Temporary directory /tmp/eb-wbzf_rxh has been removed.
$ eb git-2.30.1.eb -r
== Temporary log file in case of crash /tmp/eb-s3t9lwk_/easybuild-cvx5kpna.log
== processing EasyBuild easyconfig /apps/easybuild/easyconfigs-it4i/g/git/git-2.30.1.eb
== building and installing git/2.30.1...
== fetching files...
== creating build dir, resetting environment...
== unpacking...
== postprocessing...
== sanity checking...
== cleaning up...
== creating module...
== permissions...
== packaging...
== COMPLETED: Installation ended successfully (took 29 secs)
== Results of the build can be found in the log file(s)
/home/username/.local/easybuild/software/git/2.30.1/easybuild/easybuild-git-2.30.1-20230315.092117.log
== Temporary log file(s) /tmp/eb-s3t9lwk_/easybuild-cvx5kpna.log* have been removed.
== Temporary directory /tmp/eb-s3t9lwk_ has been removed.
If we try to build *git-2.30.1*, but we used easyconfig *git-2.25.1.eb*, change the version command `--try-software-version=2.30.1`:
$ eb git-2.25.1.eb -r --try-software-version=2.30.1
== Temporary log file in case of crash /tmp/eb-lw9itci8/easybuild-qzb7j64j.log
== processing EasyBuild easyconfig /tmp/eb-lw9itci8/tweaked_easyconfigs/git-2.30.1.eb
== building and installing git/2.30.1...
== creating build dir, resetting environment...
== unpacking...
== postprocessing...
== sanity checking...
== cleaning up...
== creating module...
== permissions...
== packaging...
== COMPLETED: Installation ended successfully (took 33 secs)
== Results of the build can be found in the log file(s)
/home/username/.local/easybuild/software/git/2.30.1/easybuild/easybuild-git-2.30.1-20230315.092313.log
== Temporary log file(s) /tmp/eb-lw9itci8/easybuild-qzb7j64j.log* have been removed.
== Temporary directory /tmp/eb-lw9itci8 has been removed.
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
```
### MODULEPATH
To see the newly installed modules, you need to add the path where they were installed to the MODULEPATH. On the cluster, you have to use the `module use` command:
```console
$ module use $HOME/.local/easybuild/modules/all/
```
or modify your `.bash_profile`:
```console
$ cat ~/.bash_profile
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
module use $HOME/.local/easybuild/modules/all/
PATH=$PATH:$HOME/bin
export PATH
```
## Build Software Using Your Own EasyConfig File
For this example, we create an EasyConfig file to build Git 2.38.1 with the *foss* toolchain. Open your favorite editor and create a file named *git-2.18.1-foss-2022b.eb* with the following content:
```
```python
easyblock = 'ConfigureMake'
name = 'git'
description = """Git is a free and open source distributed version control system designed
to handle everything from small to very large projects with speed and efficiency."""
toolchain = {'name': 'foss', 'version': '2022b'}
builddependencies = [
('binutils', '2.39'),
('Autotools', '20220317'),
]
('cURL', '7.86.0'),
('expat', '2.4.9'),
('gettext', '0.21.1'),
('Perl', '5.36.0'),
]
preconfigopts = 'make configure && '
# Work around git build system bug. If LIBS contains -lpthread, then configure
# will not append -lpthread to LDFLAGS, but Makefile ignores LIBS.
configopts = "--with-perl=${EBROOTPERL}/bin/perl --enable-pthreads='-lpthread'"
postinstallcmds = ['cd contrib/subtree; make install']
}
moduleclass = 'tools'
```
This is a simple EasyConfig. Most of the fields are self-descriptive. No build method is explicitly defined, so it uses by default the standard configure/make/make install approach.
Let us build Git with this EasyConfig file:
```console
$ eb git-2.38.1-foss-2022b.eb -r
== Temporary log file in case of crash /tmp/eb-2aiq9qr8/easybuild-eb4zenze.log
== processing EasyBuild easyconfig /home/username/git-2.38.1-foss-2022b.eb
== building and installing git/2.38.1-foss-2022b...
== creating build dir, resetting environment...
== unpacking...
== COMPLETED: Installation ended successfully (took 41 secs)
== Results of the build can be found in the log file(s)
/home/username/.local/easybuild/software/git/2.38.1-foss-2022b/easybuild/easybuild-git-2.38.1-20230315.0957
22.log
== Temporary log file(s) /tmp/eb-2aiq9qr8/easybuild-eb4zenze.log* have been removed.
== Temporary directory /tmp/eb-2aiq9qr8 has been removed.
```
We can now check that our version of Git is available via the modules:
```console
$ ml av git
------------------------------- /home/username/.local/easybuild/modules/all -------------------------------
git/2.38.1-foss-2022b
------------------------------------------ /apps/modules/devel -------------------------------------------
libgit2/1.1.0-GCCcore-10.3.0
------------------------------------------ /apps/modules/tools -------------------------------------------
git-lfs/3.1.2 git/2.32.0-GCCcore-10.3.0-nodocs
git/2.28.0-GCCcore-10.2.0-nodocs git/2.33.1-GCCcore-11.2.0-nodocs
git/2.31.1 git/2.36.0-GCCcore-11.3.0-nodocs
git/2.32.0-GCCcore-10.3.0-nodocs-test git/2.38.1-GCCcore-12.2.0-nodocs (D)
Use "module spider" to find all possible modules and extensions.
Use "module keyword key1 key2 ..." to search for all possible modules matching any of the "keys".
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
## Advanced EasyBuild Configuration
By creating the `~/.config/easybuild/config.cfg` file, you can easily specify the desired location of your software, CUDA compute capabilities, and other options that you would usually have to specify within your easyconfig or from the command line. To get an overview of all available options, use `eb --confighelp` command.
You can use our template to set all of the usual EasyBuild variables:
```console
[MAIN]
[basic]
locks-dir=EASYBUILD_ROOT/.locks/
robot=/apps/easybuild/easyconfigs-it4i:/apps/easybuild/easyconfigs-master/easybuild/easyconfigs:/apps/easybuild/easyconfigs-develop/easybuild/easyconfigs
robot-paths=/apps/easybuild/easyconfigs-it4i:/apps/easybuild/easyconfigs-master/easybuild/easyconfigs:/apps/easybuild/easyconfigs-develop/easybuild/easyconfigs
[config]
buildpath=/dev/shm/USER/build
installpath=EASYBUILD_ROOT
installpath-modules=EASYBUILD_ROOT/modules
installpath-software=EASYBUILD_ROOT/all
moduleclasses=python
repository=FileRepository
repositorypath=EASYBUILD_ROOT/file-repository
sourcepath=EASYBUILD_ROOT/sources
[easyconfig]
local-var-naming-check=error
[override]
# 8.0 for Karolina, 7.0 for Barbora
cuda-compute-capabilities=CUDA_CC
detect-loaded-modules=purge
enforce-checksums=True
silence-deprecation-warnings=True
trace=True
```
!!! note
Do not forget to add the path to your modules to MODULEPATH using the `module use` command in your `~/.bashrc` to be able to lookup and use your installed modules.
Template requires you to fill in the `EASYBUILD_ROOT`, `CUDA_CC`, and `USER` variables. `EASYBUILD_ROOT` is the top level directory which will hold all of your EasyBuild related data. `CUDA_CC` defines the CUDA compute capabilities of graphics cards, and `USER` should preferably be set to your username.
If you plan on writing more than one or two of your own easyconfigs, it might be useful to setup a custom easyconfig repository. Simply prepend it's path to the `robot` and `robot-paths` variables.
A detailed documentation regarding EasyBuild configuration is available [here][e].
[b]: https://docs.easybuild.io/
[c]: https://github.com/easybuilders/easybuild/wiki/Compiler-toolchains
[d]: https://github.com/easybuilders/easybuild-easyconfigs
[e]: https://docs.easybuild.io/configuration/