Installing Spack
Install Spack Using SStack Tool
SStack is a tool to install multiple software stacks, such as Spack, EasyBuild, conda or others. You can install Spack on Discovery through SStack as shown in the SStack Spack page.
Spack Dependencies
-
The following requirements must be installed to be able to run Spack:
-
Python
2 (2.6 or 2.7) or 3 (3.5 - 3.9)
to run Spack. -
A
C/C++
compiler for building. -
The
make
executable for building. -
The
tar, gzip, unzip, bzip2, xz
and optionallyzstd
executables for extracting source code. -
The
patch
command to apply patches. -
The
git
andcurl
commands for fetching. -
If using the
gpg
subcommand,gnupg2
is required.
-
-
These requirements are already available on Discovery, so you don’t need to install any of them.
Installing Spack
-
To install Spack, you simply need to clone its GitHub repository as follows:
git clone https://github.com/spack/spack
-
The Spack repository will be cloned in a directory called
spack
and the default branch isdevelop
. To have a stable redundancy resolution, it’s recommended using the most recent release. You can check the most recent release in the GitHub repository of Spack. The most recent release at the time of creating this documentation isv0.17
. -
To check out the most recent release (v0.17), you type:
cd spack git checkout releases/v0.17
-
To keep your current local working branch (currently checked out branch) up to date, you need to use the
git pull
command periodically. You need to make sure that you are in the Spack directory and then type:git pull
For more details on installing Spack, go to Installing Spack Documentation.
Running Spack
-
To use Spack, you need to add it to your path. You simply need to source the Spack setup script by typing:
source share/spack/setup-env.sh
-
To check if Spack has been installed successfully, you can use
which
command as follows:which spack
-
The above command will display the location of the executable file of Spack as shown in the following output:
~/spack/bin/spack
Configuration Scopes
-
Once Spack has been installed, its configuration will be stored into different directories for different scopes. Spack pulls configuration data from files in several directories. Spack searches for configuration parameters in higher-precedence scopes first. Therefore, settings in a higher-precedence file can override those with the same key in a lower-precedence one. Three different scopes are important for this documentation. The scopes are shown from lowest to highest precedences:
For more information about configuration scopes, visit Configuration Scopes in Spack.
Default Scope
-
The configuration of this scope is stored in
$SPACK_ROOT/etc/spack/defaults
. You should generally not modify the settings of this scope. Instead, you should override them in other configuration scopes.
User Scope
-
The configuration of this scope is stored in
~/.spack
. The settings of this scope affect all instances of Spack. In other words, configurations apply to any loaded/sourced Spack installation. By default,spack compiler
andspack repo
commands update the configurations of this directory. For example, when you add a new compiler usingspack compiler add
command, this will modify thecompilers.py
stored in~/.spack/linux
. You need to move thecompiler.
-
Many cache files are stored in this directory. Those files may cause an error when switching between different Spack installations. To avoid such error you need to remove the cache files using
spack clean
as follows:spack clean --all
-
This command removes:
-
All temporary build stages.
-
Cached downloads.
-
All install failure tracking markers.
-
Long-lived caches, like the virtual package index.
-
.pyc
,.pyo
files. -
Software needed to bootstrap Spack.
-
Site Scope
-
The configurations of this scope is stored in
$SPACK_ROOT/etc/spack
. The settings of this scope affect only this instance of Spack. Spack’s default configuration settings reside in$SPACK_ROOT/etc/spack/defaults
. These are useful for reference, but should never be directly edited. To override these settings, create new configuration files or copy the ones in the default scope in another location, i.e in the site scope, and change it there. -
Spack provides three environment variables to allow users to override or opt out of configuration locations:
-
SPACK_USER_CONFIG_PATH
: it overrides the path to use for the user (~/.spack
) scope. -
SPACK_SYSTEM_CONFIG_PATH
: it overrides the path to use for the system(/etc/spack
) scope. -
SPACK_DISABLE_LOCAL_CONFIG
: setting this variable totrue
disables both the system and user configuration directories. Spack will only consider its own defaults and site configuration locations. -
S`PACK_USER_CACHE_PATH
: it overrides the default path to use for user data (misc_cache, tests, reports, etc.).
-
-
To disable both the
system
anduser
configuration directories, you type:export SPACK_DISABLE_LOCAL_CONFIG=true
-
Spack will only consider its own site configuration scope because it has higher precedence than the default scope. Also, you make sure now that any update on the settings will affect the settings of the site scope
$SPACK_ROOT/etc/spack
Setting up Compilers
-
To learn how to set up compilers please refer to Customizing Compilers page.
Setting up the Micro-architecture
-
Discovery has many different micro-architecture versions and even different brands. It’s important to update the
packages.yaml
stored in$SPACK_ROOT/etc/spack/defaults/
by setting thetarget
to bex86_64
. Therefore, that you can run on any node in the Discovery cluster and not just the specific micro-architecture. To updatepackages.yaml
, you need first to copy the file from the default scope directory$SPACK_ROOT/etc/spack/defaults
to the site scope$SPACK_ROOT/etc/spack
:cp $SPACK_ROOT/etc/spack/defaults/packages.yaml $SPACK_ROOT/etc/spack
-
Then edit the copied file as follows:
vim $SPACK_ROOT/etc/spackpackages.yaml
-
Now you add
target: [x86_64]
to the file as follows:packages: all: target: [x86_64] compiler: [gcc, intel, pgi, clang, xl, nag, fj, aocc] providers: D: [ldc] ...