Spack
Introduction¶
Spack is a package manager for supercomputers, Linux, and macOS. It makes installing scientific software easy.
Spack on Euler¶
Software Stack 2025-06¶
There's a software stack deployed in /cluster/software/stacks/2025-06 which builds on Spack v0.23.1. It contains:
It can be used with modules via
module use /cluster/software/stacks/2025-06/lmod/linux-ubuntu22.04-x86_64
or with spack via
. /cluster/software/stacks/2025-06/setup-env.sh
Spack in a nutshell¶
Spack is a package manager like apt, pip, npm, cargo, yum, pacman,
zypper, winget.
At its core lies the idea of a "spec". A spec is an abstract or concrete
specification of a package's variant, the variants of its dependencies
and the compilers used to build each one. This example of an abstract
spec (whitespaces are ignored by Spack)
gromacs @2024.3 %gcc@12 ~cuda +mpi ^openmpi@5.0
means, the package gromacs at version 2024.3, built with compiler
gcc at version 12 (subversions unspecified), without variant cuda,
with mpi and dependency openmpi at version 5.0. Everything that is
unspecified is wild and spack may choose whatever it wants.
A concrete spec defines every last detail of all variants, all
dependencies, their dependencies, their variant and the compilers. The
process to turn an abstract spec into a concrete spec is called
concretization. The command to trigger it is spack spec
$ spack spec gromacs @2024.3 %gcc@12 ~cuda +mpi ^openmpi@5.0
- gromacs@2024.3%gcc@12.2.0~cp2k~cuda~cycle_subcounters~double+gmxapi+hwloc~intel_provided_gcc~ipo~mdrun_only+mpi+nblib~nosuffix~opencl+openmp~relaxed_double_precision+shared build_system=cmake build_type=Release generator=make openmp_max_threads=none arch=linux-ubuntu22.04-x86_64_v3
[^] ^openmpi@5.0.5%gcc@12.2.0+atomics~cuda~debug~gpfs~internal-hwloc~internal-libevent~internal-pmix~java~lustre~memchecker~openshmem~romio+rsh~static~two_level_namespace+vt+wrapper-rpath build_system=autotools fabrics=none romio-filesystem=none schedulers=none arch=linux-ubuntu22.04-x86_64_v3
[^] ^autoconf@2.72%gcc@12.2.0 build_system=autotools arch=linux-ubuntu22.04-x86_64_v3
[^] ^m4@1.4.19%gcc@12.2.0+sigsegv build_system=autotools patches=9dc5fbd,bfdffa7 arch=linux-ubuntu22.04-x86_64_v3
[^] ^libsigsegv@2.14%gcc@12.2.0 build_system=autotools arch=linux-ubuntu22.04-x86_64_v3
[^] ^numactl@2.0.18%gcc@12.2.0 build_system=autotools arch=linux-ubuntu22.04-x86_64_v3
[^] ^perl@5.40.0%gcc@12.2.0+cpanm+opcode+open+shared+threads build_system=generic arch=linux-ubuntu22.04-x86_64_v3
[^] ^berkeley-db@18.1.40%gcc@12.2.0+cxx~docs+stl build_system=autotools patches=26090f4,b231fcc arch=linux-ubuntu22.04-x86_64_v3
[^] ^pkgconf@2.2.0%gcc@12.2.0 build_system=autotools arch=linux-ubuntu22.04-x86_64_v3
Install a package¶
To install a package that's in spack, first get some info about the package with
spack info
Then define your spec and concretize it with
spack spec
Inspect the output and modify your spec until you're satisfied with the concrete spec. Then install the package and its dependencies with
spack install
To add the package to your user environment, load it via
spack load
Now you can use the package.
Build external software¶
To build software that's not registered in Spack, it may be sufficient to load 1 or 2 packages and start the build process, like
spack load cmake @3.30.5 %gcc@12
spack load openmpi @5.0.5 %gcc@12
cmake -B build
cmake --build build
if this is not the case, environments might be a good solution.
Create an
environment
with
spack env create --dir
This will create a folder
spack env activate -p
-p adds the active environment to the command line prompt. Now you can add specs to the env
spack add
spack add
...
Concretize it, install it, load it and start your build process
spack concretize
spack install
spack load
cmake -B build
cmake --build build
Write/Extend packages¶
If the packages in Spack are not
sufficient for you, you can write your own packages or extend existing
ones. A simple way to do this is
StackySpack, which
configures Spack to look for additional packages in one of StackySpack's
folders. StackySpack can be used with any software stack (aka upstream,
in Spack's lingo), not just the ones on Euler.
And of course the Spack community welcomes contributions to their
package repository as well: https://github.com/spack/spack-packages
Command cheat sheet¶
Spec
syntax:
| Header text | Header text |
|---|---|
| spack find | Lists all installed packages. |
| spack find |
Lists all installed packages that match the spec. |
| spack info |
Prints information of the package. |
| spack spec |
Concretizes abstract spec. (Unspecified variants are wild.) |
| spack install |
Concretizes spec and installs package and dependencies. |
| spack location --install-dir |
Prints the location of all installs that satisfy the spec. |
| spack load |
Loads run environment of package and dependencies. |
| spack env activate -p |
Set the active environment. (-p adds the active environment to the command line prompt) |
| spack env deactivate | Deactivates the active environment. |