Use Spack#
2025-01-28
17 min read time
Spack is a package management tool designed to support multiple software versions and configurations on a wide variety of platforms and environments. It was designed for large supercomputing centers, where many users share common software installations on clusters with exotic architectures using libraries that do not have a standard ABI. Spack is non-destructive: installing a new version does not break existing installations, so many configurations can coexist on the same system.
Most importantly, Spack is simple. It offers a simple spec
syntax, so users
can concisely specify versions and configuration options. Spack is also simple
for package authors: package files are written in pure Python, and specs allow
package authors to maintain a single file for many different builds of the same
package.
See the official Spack documentation for more information.
Installing prerequisites for Spack#
Note
You must install all prerequisites before installing Spack.
# Install some essential utilities:
apt-get update
apt-get install make patch bash tar gzip unzip bzip2 file gnupg2 git gawk
apt-get update -y
apt-get install -y xz-utils
apt-get install build-essential
apt-get install vim
apt-get install libpci-dev
# Install Python:
apt-get install python3
apt-get upgrade python3-pip
# Install Compilers:
apt-get install gcc
apt-get install gfortran
# Install some essential utilities:
zypper update
zypper install make patch bash tar gzip unzip bzip xz file gnupg2 git awk
zypper in -t pattern
zypper install vim
# Install Python:
zypper install python3
zypper install python3-pip
# Install Compilers:
zypper install gcc
zypper install gcc-fortran
zypper install gcc-c++
Building ROCm components using Spack#
To use the Spack package manager, clone the Spack project from spack/spack.
git clone https://github.com/spack/spack.git
Initialize Spack.
The
setup-env.sh
script initializes the Spack environment.cd spack . share/spack/setup-env.sh
Spack commands are available once the above steps are completed. To list the available commands, use
help
.spack help
ROCm packages in Spack#
Component |
Spack package name |
Minimum supported version |
Latest supported version |
---|---|---|---|
aqlprofile |
|
5.5.0 |
6.3.1 |
comgr |
|
5.5.0 |
6.3.1 |
Composable Kernel |
|
5.5.0 |
6.3.1 |
devicelibs |
|
5.5.0 |
6.3.1 |
HIP (hip_in_vdi) |
|
5.5.0 |
6.3.1 |
hipBLAS |
|
5.5.0 |
6.3.1 |
hipBLASLt |
|
6.0.0 |
6.3.1 |
HIPCC |
|
5.7.0 |
6.3.1 |
hipCUB |
|
5.5.0 |
6.3.1 |
hipFFT |
|
5.5.0 |
6.3.1 |
hipfort |
|
5.5.0 |
6.3.1 |
HIPIFY |
|
5.5.0 |
6.3.1 |
hipRAND |
|
5.5.0 |
6.3.1 |
hipSOLVER |
|
5.5.0 |
6.3.1 |
hipSPARSE |
|
5.5.0 |
6.3.1 |
hipSPARSELt |
|
6.0.0 |
6.3.1 |
hipTensor |
|
5.7.0 |
6.3.1 |
lightning |
|
5.5.0 |
6.3.1 |
MIOpen (HIP) |
|
5.5.0 |
6.3.1 |
MIGraphX |
|
5.5.0 |
6.3.1 |
MIVisionX |
|
5.5.0 |
6.3.1 |
Omnitrace |
|
rocm-6.2.0 |
rocm-6.3.0 |
OpenCL |
|
5.5.0 |
6.3.1 |
openmp-extras |
|
5.5.0 |
6.3.1 |
RCCL |
|
5.5.0 |
6.3.1 |
rocAL |
|
6.2.0 |
6.3.1 |
rocALUTION |
|
5.5.0 |
6.3.1 |
rocBLAS |
|
5.5.0 |
6.3.1 |
ROCdbgapi |
|
5.5.0 |
6.3.1 |
rocDecode |
|
6.1.0 |
6.3.1 |
rocFFT |
|
5.5.0 |
6.3.1 |
rocm-core |
|
5.5.0 |
6.3.1 |
rocminfo |
|
5.5.0 |
6.3.1 |
ROCm Bandwidth Test |
|
5.5.0 |
6.3.1 |
rocm-cmake |
|
5.5.0 |
6.3.1 |
ROCm Compute Profiler (rocprofiler-compute) |
|
6.2.0 |
6.3.1 |
ROCm Data Center Tool (RDC) |
|
5.5.0 |
6.3.1 |
ROCm Debug Agent |
|
5.5.0 |
6.3.1 |
ROCm Debugger (ROCgdb) |
|
5.5.0 |
6.3.1 |
rocMLIR |
|
5.4.0 |
6.3.1 |
ROCm SMI Library |
|
5.5.0 |
6.3.1 |
ROCm Systems Profiler (rocprofiler-systems) |
|
6.2.0 |
6.3.1 |
ROCm Validation Suite |
|
5.5.0 |
6.3.1 |
rocPRIM |
|
5.5.0 |
6.3.1 |
ROCProfiler |
|
5.5.0 |
6.3.1 |
rocprofiler-register |
|
6.1.0 |
6.3.1 |
rocPyDecode |
|
6.2.0 |
6.3.1 |
rocRAND |
|
5.5.0 |
6.3.1 |
ROCr Runtime |
|
5.5.0 |
6.3.1 |
rocSOLVER |
|
5.5.0 |
6.3.1 |
rocSPARSE |
|
5.5.0 |
6.3.1 |
rocThrust |
|
5.5.0 |
6.3.1 |
ROCTracer |
|
5.5.0 |
6.3.1 |
roctracer-dev-api |
|
5.5.0 |
6.3.1 |
rocWMMA |
|
5.5.0 |
6.3.1 |
ROCm Performance Primitives (RPP) |
|
5.7.0 |
6.3.1 |
Tensile |
|
5.5.0 |
6.3.1 |
atmi |
|
5.5.0 |
5.5.1 (final) |
clang-ocl |
|
5.5.0 |
6.1.2 (final) |
mlirmiopen |
|
5.3.0 |
5.4.0 (deprecated) |
MIOpen (GEMM) |
|
5.5.0 |
5.5.1 (final) |
MIOpen (OpenCL) |
|
5.5.0 |
5.5.1 (final) |
rocclr (vdi) |
|
5.5.0 |
5.6.1 (final) |
ROCT Thunk Interface |
|
5.5.0 |
6.2.4 (final) |
Installing ROCm components using Spack#
rocm-cmake
Install the default variants and the latest version of
rocm-cmake
.spack install rocm-cmake
To install a specific version of
rocm-cmake
, use:spack install rocm-cmake@<version number>
For example,
spack install [email protected]
info
The
info
command displays basic package information. It shows the preferred, safe, and deprecated versions, in addition to the available variants. It also shows the dependencies with other packages.spack info mivisionx
For example:
spack info mivisionx CMakePackage: mivisionx Description: MIVisionX toolkit is a set of comprehensive computer vision and machine intelligence libraries, utilities, and applications bundled into a single toolkit. Homepage: <https://github.com/GPUOpen-ProfessionalCompute-Libraries/MIVisionX> Preferred version: 6.3.1 https://github.com/GPUOpen-ProfessionalCompute-Libraries/MIVisionX/archive/rocm-6.3.1.tar.gz Safe versions: 6.3.1 https://github.com/GPUOpen-ProfessionalCompute-Libraries/MIVisionX/archive/rocm-6.3.1.tar.gz 6.3.0 https://github.com/GPUOpen-ProfessionalCompute-Libraries/MIVisionX/archive/rocm-6.3.0.tar.gz 6.2.4 https://github.com/GPUOpen-ProfessionalCompute-Libraries/MIVisionX/archive/rocm-6.2.4.tar.gz 6.2.1 https://github.com/GPUOpen-ProfessionalCompute-Libraries/MIVisionX/archive/rocm-6.2.1.tar.gz 6.2.0 https://github.com/GPUOpen-ProfessionalCompute-Libraries/MIVisionX/archive/rocm-6.2.0.tar.gz 6.1.2 https://github.com/GPUOpen-ProfessionalCompute-Libraries/MIVisionX/archive/rocm-6.1.2.tar.gz 6.1.1 https://github.com/GPUOpen-ProfessionalCompute-Libraries/MIVisionX/archive/rocm-6.1.1.tar.gz 6.1.0 https://github.com/GPUOpen-ProfessionalCompute-Libraries/MIVisionX/archive/rocm-6.1.0.tar.gz 6.0.2 https://github.com/GPUOpen-ProfessionalCompute-Libraries/MIVisionX/archive/rocm-6.0.2.tar.gz 6.0.0 https://github.com/GPUOpen-ProfessionalCompute-Libraries/MIVisionX/archive/rocm-6.0.0.tar.gz 5.7.1 https://github.com/GPUOpen-ProfessionalCompute-Libraries/MIVisionX/archive/rocm-5.7.1.tar.gz 5.7.0 https://github.com/GPUOpen-ProfessionalCompute-Libraries/MIVisionX/archive/rocm-5.7.0.tar.gz 5.6.1 https://github.com/GPUOpen-ProfessionalCompute-Libraries/MIVisionX/archive/rocm-5.6.1.tar.gz 5.6.0 https://github.com/GPUOpen-ProfessionalCompute-Libraries/MIVisionX/archive/rocm-5.6.0.tar.gz 5.5.1 https://github.com/GPUOpen-ProfessionalCompute-Libraries/MIVisionX/archive/rocm-5.5.1.tar.gz 5.5.0 https://github.com/GPUOpen-ProfessionalCompute-Libraries/MIVisionX/archive/rocm-5.5.0.tar.gz Deprecated versions: 5.4.3 https://github.com/GPUOpen-ProfessionalCompute-Libraries/MIVisionX/archive/rocm-5.4.3.tar.gz 5.4.0 https://github.com/GPUOpen-ProfessionalCompute-Libraries/MIVisionX/archive/rocm-5.4.0.tar.gz 5.3.3 https://github.com/GPUOpen-ProfessionalCompute-Libraries/MIVisionX/archive/rocm-5.3.3.tar.gz 5.3.0 https://github.com/GPUOpen-ProfessionalCompute-Libraries/MIVisionX/archive/rocm-5.3.0.tar.gz Variants: add_tests [false] false, true add tests and samples folder asan [false] false, true Build with address-sanitizer enabled or disabled build_system [cmake] cmake Build systems supported by the package hip [true] false, true Use HIP as backend opencl [false] false, true Use OPENCL as the backend when build_system=cmake build_type [Release] Debug, MinSizeRel, RelWithDebInfo, Release CMake build type generator [make] none the build system generator to use when build_system=cmake ^[email protected]: ipo [false] false, true CMake interprocedural optimization Build Dependencies: cmake gmake libjpeg-turbo migraphx miopen-opencl ninja openssl py-future py-numpy py-pybind11 py-setuptools python rocm-core rpp ffmpeg hip lmdb miopen-hip miopengemm opencv protobuf py-google-api-python-client py-protobuf py-pytz py-wheel rapidjson rocm-opencl Link Dependencies: hip migraphx miopen-opencl openssl py-google-api-python-client py-pybind11 py-setuptools rapidjson rocm-opencl lmdb miopen-hip miopengemm py-future py-numpy py-pytz py-wheel rocm-core rp Run Dependencies: py-protobuf Licenses: MIT
Installing variants for ROCm components#
The variants listed above indicate that the mivisionx
package is built by
default with build_type=Release
and the hip
backend, and without the
opencl
backend. build_type=Debug
and RelWithDebInfo
, with opencl
and without hip
, are also supported.
For example:
spack install mivisionx build_type=Debug #Backend will be hip since it is the default one
spack install mivisionx+opencl build_type=Debug #Backend will be opencl and hip will be disabled as per the conflict defined in recipe
spack spec
commandTo display the dependency tree, the
spack spec
command can be used with the same format.For example:
spack spec mivisionx [email protected]%[email protected]~add_tests~asan+hip~ipo~opencl build_system=cmake build_type=Release generator=make arch=linux-rhel9-skylake_avx512 ^[email protected]%[email protected]~doc+ncurses+ownlibs~qtgui build_system=generic build_type=Release arch=linux-rhel8-skylake_avx512 ^[email protected]%[email protected]~gssapi~ldap~libidn2~librtmp~libssh~libssh2+nghttp2 build_system=autotools libs=shared,static tls=openssl arch=linux-rhel8-skylake_avx512 ^[email protected]%[email protected] build_system=autotools arch=linux-rhel8-skylake_avx512 ^[email protected]%[email protected] build_system=generic arch=linux-rhel8-skylake_avx512 ^[email protected]%[email protected] build_system=autotools arch=linux-rhel8-skylake_avx512 ^[email protected]%[email protected]~symlinks+termlib abi=none build_system=autotools patches=7a351bc arch=linux-rhel8-skylake_avx512 ^[email protected]%[email protected]+compat+new_strategies+opt+pic+shared build_system=autotools arch=linux-rhel8-skylake_avx512 ^[email protected]%[email protected]~X~avresample+bzlib~doc~drawtext+gpl~libaom~libmp3lame~libopenjpeg~libopus~libsnappy~libspeex~libssh~libvorbis~libvpx~libwebp~libx264~libxml2~libzmq~lzma~nonfree~openssl~sdl2+shared+version3 build_system=autotools patches=f070ac1 arch=linux-rhel8-skylake_avx51
Creating an environment#
You can create an environment with all the required components of your version.
In the root folder, create a new folder when you can create a
.yaml
file. This file is used to create an environment.mkdir /localscratch cd /localscratch vi sample.yaml
Add all the required components in the
sample.yaml
file:spack: concretization: separately packages: all: compiler: [[email protected]] specs: - matrix: - ['%[email protected]\^[email protected]'] - [[email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected]] view: true
Once you’ve created the
.yaml
file, you can use it to create an environment.spack env create -d /localscratch/MyEnvironment /localscratch/sample.yaml
Activate the created environment.
spack env activate /localscratch/MyEnvironment
Before installing, verify that you want all the component versions.
spack find # this command will list out all components been in the environment (and 0 installed )
Install all the components in the
.yaml
file.cd /localscratch/MyEnvironment spack install -j 50
Check that all components are successfully installed.
spack find
If any modification is made to the
.yaml
file, you must deactivate the existing environment and create a new one in order for the modifications to be reflected.To deactivate, use:
spack env deactivate
Creating and applying a patch before installation#
Spack installs ROCm packages after pulling the source code from GitHub and building it locally. In order to build a component with any modification to the source code, you must generate a patch and apply it before the build phase.
To generate a patch and build with the changes:
Stage the source code. For example:
spack stage [email protected] # (This will pull the 6.3.1 release version source code of hip and display the path to spack-src directory where entire source code is available)
You should see something like this:
==> Using cached archive: /data/root/temp/rocm-6.3/spack/var/spack/cache/_source-cache/archive/d8/d8dba8cdf05463afb7879de2833983cafa6a006ba719815a35b96d9b92fc7fc4.tar.gz ==> Using cached archive: /data/root/temp/rocm-6.3/spack/var/spack/cache/_source-cache/archive/82/829e61a5c54d0c8325d02b0191c0c8254b5740e63b8bfdb05eec9e03d48f7d2c.tar.gz ==> Using cached archive: /data/root/temp/rocm-6.3/spack/var/spack/cache/_source-cache/archive/80/8081d4ab1a43ffa1cebd646668d83008b799ab98c14daf7b455922355a439c8a.tar.gz ==> Moving resource stage source: /tmp/root/spack-stage/resource-clr-zo53ondw3tevsr3gmoofbhre7asvis46/spack-src/ destination: /tmp/root/spack-stage/spack-stage-hip-6.3.1-zo53ondw3tevsr3gmoofbhre7asvis46/spack-src/clr ==> Moving resource stage source: /tmp/root/spack-stage/resource-hip-tests-zo53ondw3tevsr3gmoofbhre7asvis46/spack-src/ destination: /tmp/root/spack-stage/spack-stage-hip-6.3.1-zo53ondw3tevsr3gmoofbhre7asvis46/spack-src/hip-tests ==> Staged hip in /tmp/root/spack-stage/spack-stage-hip-6.3.1-zo53ondw3tevsr3gmoofbhre7asvis46
Change directory to
spack-src
inside the staged directory.root@computername:/spack$ cd /tmp/root/spack-stage/spack-stage-hip-6.3.1-zo53ondw3tevsr3gmoofbhre7asvis46 root@computername:/tmp/root/spack-stage/spack-stage-hip-6.3.1-zo53ondw3tevsr3gmoofbhre7asvis46$ cd spack-src/
Create a new Git repository.
root@computername:/tmp/root/spack-stage/spack-stage-hip-6.3.1-zo53ondw3tevsr3gmoofbhre7asvis46/spack-src$ git init
Add the entire directory to the repository.
root@computername:/tmp/root/spack-stage/spack-stage-hip-6.3.1-zo53ondw3tevsr3gmoofbhre7asvis46/spack-src$ git add .
Make the required changes to the source code.
root@computername:/tmp/root/spack-stage/spack-stage-hip-6.3.1-zo53ondw3tevsr3gmoofbhre7asvis46/spack-src# vi hipamd/CMakeLists.txt # Make required changes in the source code
Generate the patch using the
git diff
command.diff > /spack/var/spack/repos/builtin/packages/hip/0001-modifications.patch root@computername:/tmp/root/spack-stage/spack-stage-hip-6.3.1-zo53ondw3tevsr3gmoofbhre7asvis46/spack-src$ git diff > /spack/var/spack/repos/builtin/packages/hip/0001-modifications.patch
Update the recipe with the patch file name and any conditions you want to apply.
root@computername:/tmp/root/spack-stage/spack-stage-hip-6.3.1-zo53ondw3tevsr3gmoofbhre7asvis46/spack-src$ spack edit hip
Provide the patch file name and the conditions for the patch to be applied in the
hip
recipe as follows.patch("0001-modifications.patch", when="@6.3.1")
Spack will apply
0001-modifications.patch
on the 6.3.1 release code before starting thehip
build.After each modification, you must update the recipe. If there is no change to the recipe, run
touch /spack/var/spack/repos/builtin/packages/hip/package.py