Update Installing dolfinx with spack on Habrok authored by D.J. Nolte's avatar D.J. Nolte
Content:
[[_TOC_]] [[_TOC_]]
[Spack](https://github.com/spack/spack) is a package management tool designed for HPC, allowing to easily build optimized software in multiple versions and configurations. Many packages are supported (see the [package list](https://spack.readthedocs.io/en/latest/package_list.html)), among them the fenicsx/dolfinx package [py-fenics-dolfinx](https://spack.readthedocs.io/en/latest/package_list.html#py-fenics-dolfinx). [Spack](https://github.com/spack/spack) is a package management tool designed for HPC, allowing to easily build optimized software in multiple versions and configurations. Many packages are supported (see the [package list](https://spack.readthedocs.io/en/latest/package_list.html)), among them the fenicsx/dolfinx package [py-fenics-dolfinx](https://spack.readthedocs.io/en/latest/package_list.html#py-fenics-dolfinx).
...@@ -64,39 +66,58 @@ Let Spack detect all additional system modules: ...@@ -64,39 +66,58 @@ Let Spack detect all additional system modules:
spack external find spack external find
``` ```
To install newly released package versions, Spack has to be updated with a `git pull` in the Spack repository.
## dolfinx installation ## dolfinx installation
### Environment setup
Create a new Spack environment, for instance with the name `fenicsx` and activate it: Create a new Spack environment, for instance with the name `fenicsx` and activate it:
```sh ```sh
spack env create fenicsx spack env create fenicsx
spack env activate fenicsx spack env activate fenicsx -p
``` ```
Add the dolfinx package to the environment: Add the dolfinx package to the environment:
```sh ```sh
spack add py-fenics-dolfinx@main arch=linux-rocky8-zen3 cflags="-O3" fflags="-O3"
```
This will select the latest development versions of the FEniCS ecosystem, corresponding to the `main` branches. To install the latest stable release (at the time of writing `v0.6.0`, see the list of tags [here](https://spack.readthedocs.io/en/latest/package_list.html#py-fenics-dolfinx)), use
```sh
spack add py-fenics-dolfinx arch=linux-rocky8-zen3 cflags="-O3" fflags="-O3" spack add py-fenics-dolfinx arch=linux-rocky8-zen3 cflags="-O3" fflags="-O3"
``` ```
This will select the latest stable release (at the time of writing `v0.6.0`, see the list of tags [here](https://spack.readthedocs.io/en/latest/package_list.html#py-fenics-dolfinx)). To install the development version, use `py-fenics-dolfinx@main`. Our codes require the development version.
The -O3 compiler flags optionally apply level 3 optimization (https://github.com/FEniCS/dolfinx#spack). The -O3 compiler flags optionally apply level 3 optimization (https://github.com/FEniCS/dolfinx#spack).
The `arch` setting specifies the [microarchitecture](https://spack.readthedocs.io/en/latest/basic_usage.html#support-for-specific-microarchitectures) to determine the optimal compiler flags. The `arch` setting specifies the [microarchitecture](https://spack.readthedocs.io/en/latest/basic_usage.html#support-for-specific-microarchitectures) to determine the optimal compiler flags.
Usually Spack will detect the correct settings automatically, if not compiling for a different machine. Usually Spack will detect the correct settings automatically, if not compiling for a different machine.
Because the login node and the compute nodes use different processors, in the command above we enforce the target archictecture for the compute nodes (`zen3`). (Confirm with `srun -n 1 spack arch`.) Because the login node and the compute nodes use different processors, in the command above we enforce the target architecture for the compute nodes (`zen3`). (Confirm with `srun -n 1 spack arch`.)
This setting may not be necessary if we compile the packages on a compute node instead of the login node (strongly recommended). This setting may not be necessary if we compile the packages on a compute node instead of the login node (strongly recommended).
**NOTE** (31-05-2023): To install `dolfinx@main` with ADIOS2 support for visualization, the following works: **NOTE**: Optional dependencies
To install dolfinx with ADIOS2 support for visualization, the optional `adios2` dependency must be activated in the `fenics-dolfinx` package (a dependency of `py-fenics-dolfinx`).
```sh ```sh
spack add adios2@2.8.3 arch=linux-rocky8-zen3
spack add fenics-dolfinx@main +adios2 arch=linux-rocky8-zen3 cflags="-O3" fflags="-O3" spack add fenics-dolfinx@main +adios2 arch=linux-rocky8-zen3 cflags="-O3" fflags="-O3"
spack add py-fenics-dolfinx arch=linux-rocky8-zen3 cflags="-O3" fflags="-O3" spack add py-fenics-dolfinx arch=linux-rocky8-zen3 cflags="-O3" fflags="-O3"
``` ```
(The default version `adios2@2.9.0` produces files that cannot be opened with ParaView 5.11.1.) In order to add MUMPS to PETSc (not installed by default), do:
In order to add MUMPS to petsc (not installed by default):
```sh ```sh
spack add petsc +mumps arch=linux-rocky8-zen3 spack add petsc +mumps arch=linux-rocky8-zen3 cflags="-O3" fflags="-O3"
``` ```
Other options of interest are, e.g., choosing the partitioner, see `spack info fenics-dolfinx` and `spack info petsc`. Other options of interest are, e.g., choosing the partitioner, see `spack info fenics-dolfinx` and `spack info petsc`.
Now the packages can be installed with `spack install`. This may take a while, so better create a job for a compute node: **Summary of the recommended environment for CHiMERA:**
```sh
spack add petsc +mumps arch=linux-rocky8-zen3 cflags="-O3" fflags="-O3"
spack add fenics-dolfinx@main +adios2 arch=linux-rocky8-zen3 cflags="-O3" fflags="-O3"
spack add py-fenics-dolfinx arch=linux-rocky8-zen3 cflags="-O3" fflags="-O3"
spack add py-pip py-h5py arch=linux-rocky8-zen3
```
### Installation
Now the packages can be installed with `spack install`. Create a job for a compute node:
```sh ```sh
#!/bin/bash #!/bin/bash
...@@ -110,8 +131,13 @@ source $HOME/spack/share/spack/setup-env.sh ...@@ -110,8 +131,13 @@ source $HOME/spack/share/spack/setup-env.sh
spack env activate fenicsx spack env activate fenicsx
srun spack install srun spack install
``` ```
and run the job with `sbatch job.sh`. and run the job with
dolfinx should now be installed. Check the logs if openmpi and openblas were correctly picked up from the system instead of compiling them from source. ```sh
sbatch job.sh
```
dolfinx should now be installed. Check the logs if OpenMPI and OpenBLAS were correctly picked up from the system instead of compiling them from source.
### Test the installation
Test your installation with, e.g., Test your installation with, e.g.,
```sh ```sh
... ...
......