Spack

Spack is an open-source package manager that allows the developers to easily manage multiple versions of the same software and its dependencies, for example by allowing to quickly switch between multiple CUDA or gcc versions.

Installation

Let's get started with Spack on DataCrunch On-demand cluster!

On your first boot, Spack is not added to your shell by default. To initialize Spack, please run:

. /home/spack/spack/share/spack/setup-env.sh

The above can also be added to your .bashrc to have Spack commands always available on login.

Basic usage

We recommend you consult Spack documentation to learn more about its features. Below, we provide some basic examples.

You can make the specific version of a package active by running spack load package@version and conversely, deactivating it by running spack unload package. Behind the scenes, Spack handles the above by prepending to the $PATH environment variable.

Example commands

List the currently installed packages:

spack find

On a freshly installed cluster this should provide output similar to:

To find info on all installable versions of Nvidia CUDA:

spack info cuda

To install CUDA version 12.6.2:

spack install [email protected]

Once the package has been installed load it with:

spack load [email protected]

Verify that the package has been loaded:

spack find --loaded | grep cuda

Now the Nvidia CUDA Compiler path will be set to the Spack module corresponding to the loaded CUDA version:

which nvcc

Should output something like:

/home/spack/spack/opt/.../cuda-12.6.2-fguwwqog63caubyxg2q4mgcce5n5rmrv/bin/nvcc

Troubleshooting

The Spack setup script is available here: /usr/local/bin/spack.setup.sh. If you for any reason delete your /home/spack directory, you can recreate it by running the above script.

We recommend you read spack.setup.sh before using it. It for example sets cuda_arch=90a which is not the right choice for NVIDIA GPU generations newer than H200.

Last updated

Was this helpful?