Using Spack to install ROCm packages#

2025-11-19

15 min read time

Applies to Linux

Spack is a package management tool designed to support multiple softwareversions and configurations on a wide variety of platforms and environments. Itwas designed for large supercomputing centers, where many users share commonsoftware installations on clusters with exotic architectures using librariesthat do not have a standard ABI. Spack is non-destructive: installing a newversion does not break existing installations, so many configurations cancoexist on the same system.

Most importantly, Spack is simple. It offers a simplespec syntax, so userscan concisely specify versions and configuration options. Spack is also simplefor package authors: package files are written in pure Python, and specs allowpackage authors to maintain a single file for many different builds of the samepackage.

See theofficial Spack documentation for more information.

Installing prerequisites for Spack#

Note

You must install all prerequisites before installing Spack.

# Install some essential utilities:apt-getupdateapt-getinstallmakepatchbashtargzipunzipbzip2filegnupg2gitgawkapt-getupdate-yapt-getinstall-yxz-utilsapt-getinstallbuild-essentialapt-getinstallvimapt-getinstalllibpci-dev# Install Python:apt-getinstallpython3apt-getupgradepython3-pip# Install Compilers:apt-getinstallgccapt-getinstallgfortran
# Install some essential utilities:zypperupdatezypperinstallmakepatchbashtargzipunzipbzipxzfilegnupg2gitawkzypperin-tpatternzypperinstallvim# Install Python:zypperinstallpython3zypperinstallpython3-pip# Install Compilers:zypperinstallgcczypperinstallgcc-fortranzypperinstallgcc-c++

Building ROCm components using Spack#

  1. To use the Spack package manager, clone the Spack project fromspack/spack.

    gitclonehttps://github.com/spack/spack.git
  2. Initialize Spack.

    Thesetup-env.sh script initializes the Spack environment.

    cdspack.share/spack/setup-env.sh

    Spack commands are available once the above steps are completed. To list the available commands, usehelp.

    spackhelp

After runningsetup-env.sh, the develop branch of theSpack packages repository will be cloned and used.

Note

To use your own local version of spack packages execute the following command:

spackreposet--destination/path/to/local/spack-packagesbuiltin

ROCm packages in Spack#

Note

The supported ROCm components and their versions listed below were accurate as of the time of initial ROCm release. For the most up-to-date information, see the latest version of this information atROCm packages in Spack.

Component

Spack package name

Minimum supported version

Latest supported version

AMD SMI

amdsmi

5.6.0

7.0.2

aqlprofile

hsa-amd-aqlprofile

7.0.0

7.0.2

comgr

comgr

5.6.0

7.0.2

Composable Kernel

composable-kernel

5.6.0

7.0.2

devicelibs

rocm-device-libs

5.6.0

7.0.2

HIP (hip_in_vdi)

hip

5.6.0

7.0.2

hipBLAS

hipblas

5.6.0

7.0.2

hipBLASLt

hipblaslt

6.0.0

7.0.2

HIPCC

hipcc

5.7.0

7.0.2

hipCUB

hipcub

5.6.0

7.0.2

hipFFT

hipfft

5.6.0

7.0.2

hipfort

hipfort

5.6.0

7.0.2

HIPIFY

hipify-clang

5.6.0

7.0.2

hipRAND

hiprand

5.6.0

7.0.2

hipSOLVER

hipsolver

5.6.0

7.0.2

hipSPARSE

hipsparse

5.6.0

7.0.2

hipSPARSELt

hipsparselt

6.0.0

7.0.2

hipTensor

hip-tensor

5.7.0

7.0.2

HIP Tests

hip-tests

6.1.0

7.0.2

lightning

llvm-amdgpu

5.6.0

7.0.2

MIOpen (HIP)

miopen-hip

5.6.0

7.0.2

MIGraphX

migraphx

5.6.0

7.0.2

MIVisionX

mivisionx

5.6.0

7.0.2

OpenCL

rocm-opencl

5.6.0

7.0.2

openmp-extras

rocm-openmp-extras

5.6.0

7.0.2

RCCL

rccl

5.6.0

7.0.2

rocAL

rocal

6.2.0

7.0.2

rocALUTION

rocalution

5.6.0

7.0.2

rocBLAS

rocblas

5.6.0

7.0.2

ROCdbgapi

rocm-dbgapi

5.6.0

7.0.2

rocDecode

rocdecode

6.1.0

7.0.2

rocFFT

rocfft

5.6.0

7.0.2

rocJPEG

rocjpeg

6.3.0

7.0.2

rocm-core

rocm-core

5.6.0

7.0.2

rocminfo

rocminfo

5.6.0

7.0.2

rocMLIR

rocmlir

5.4.0

7.0.2

ROCm Bandwidth Test

rocm-bandwidth-test

5.6.0

7.0.2

rocm-cmake

rocm-cmake

5.6.0

7.0.2

ROCm Compute Profiler

rocprofiler-compute

6.3.2

7.0.2

ROCm Data Center Tool (RDC)

rdc

5.6.0

7.0.2

ROCm Debug Agent

rocm-debug-agent

5.6.0

7.0.2

ROCm Debugger (ROCgdb)

rocm-gdb

5.6.0

7.0.2

ROCm Examples

rocm-examples

6.2.0

7.0.2

ROCm SMI Library

rocm-smi-lib

5.6.0

7.0.2

ROCm Systems Profiler

rocprofiler-systems

6.3.0

7.0.2

ROCm Validation Suite

rocm-validation-suite

5.6.0

7.0.2

rocPRIM

rocprim

5.6.0

7.0.2

ROCProfiler

rocprofiler-dev

5.6.0

7.0.2

rocprofiler-register

rocprofiler-register

6.1.0

7.0.2

ROCprofiler-SDK

rocprofiler-sdk

6.2.4

7.0.2

rocPyDecode

rocpydecode

6.2.0

7.0.2

rocRAND

rocrand

5.6.0

7.0.2

ROCr Runtime

hsa-rocr-dev

5.6.0

7.0.2

rocSHMEM

rocshmem

6.4.0

7.0.2

rocSOLVER

rocsolver

5.6.0

7.0.2

rocSPARSE

rocsparse

5.6.0

7.0.2

rocThrust

rocthrust

5.6.0

7.0.2

ROCTracer

roctracer-dev

5.6.0

7.0.2

roctracer-dev-api

roctracer-dev-api

5.6.0

7.0.2

rocWMMA

rocwmma

5.6.0

7.0.2

ROCm Performance Primitives (RPP)

rpp

5.7.0

7.0.2

Tensile

rocm-tensile

5.6.0

7.0.2

TransferBench

transferbench

6.3.0

7.0.2

aqlprofile (old)

aqlprofile

5.6.0

6.4.3 (final)

clang-ocl

rocm-clang-ocl

5.6.0

6.1.2 (final)

Omniperf

omniperf

6.2.0

6.3.1 (final)

Omnitrace

omnitrace

rocm-6.2.0

rocm-6.3.0 (final)

ROCT Thunk Interface

hsakmt-roct

5.6.0

6.2.4 (final)

Installing ROCm components using Spack#

  1. rocm-cmake

    Install the default variants and the latest version ofrocm-cmake.

    spackinstallrocm-cmake

    To install a specific version ofrocm-cmake, use:

    spackinstallrocm-cmake@<versionnumber>

    For example,spackinstallrocm-cmake@7.0.2

  2. info

    Theinfo command displays basic package information. It shows the preferred, safe, anddeprecated versions, in addition to the available variants. It also shows the dependencies with otherpackages.

    spackinfomivisionx

    For example:

    $spackinfomivisionxCMakePackage:   mivisionxDescription:    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/ROCm/MIVisionXPreferred version:    7.0.2    https://github.com/ROCm/MIVisionX/archive/rocm-7.0.2.tar.gzSafe versions:    7.0.0    https://github.com/ROCm/MIVisionX/archive/rocm-7.0.0.tar.gz    6.4.3    https://github.com/ROCm/MIVisionX/archive/rocm-6.4.3.tar.gz    6.4.3    https://github.com/ROCm/MIVisionX/archive/rocm-6.4.3.tar.gz    6.4.2    https://github.com/ROCm/MIVisionX/archive/rocm-6.4.2.tar.gz    6.4.1    https://github.com/ROCm/MIVisionX/archive/rocm-6.4.1.tar.gz    6.4.0    https://github.com/ROCm/MIVisionX/archive/rocm-6.4.0.tar.gz    6.3.3    https://github.com/ROCm/MIVisionX/archive/rocm-6.3.3.tar.gz    6.3.2    https://github.com/ROCm/MIVisionX/archive/rocm-6.3.2.tar.gz    6.3.1    https://github.com/ROCm/MIVisionX/archive/rocm-6.3.1.tar.gz    6.3.0    https://github.com/ROCm/MIVisionX/archive/rocm-6.3.0.tar.gz    6.2.4    https://github.com/ROCm/MIVisionX/archive/rocm-6.2.4.tar.gz    6.2.1    https://github.com/ROCm/MIVisionX/archive/rocm-6.2.1.tar.gz    6.2.0    https://github.com/ROCm/MIVisionX/archive/rocm-6.2.0.tar.gz    6.1.2    https://github.com/ROCm/MIVisionX/archive/rocm-6.1.2.tar.gz    6.1.1    https://github.com/ROCm/MIVisionX/archive/rocm-6.1.1.tar.gz    6.1.0    https://github.com/ROCm/MIVisionX/archive/rocm-6.1.0.tar.gz    6.0.2    https://github.com/ROCm/MIVisionX/archive/rocm-6.0.2.tar.gz    6.0.0    https://github.com/ROCm/MIVisionX/archive/rocm-6.0.0.tar.gz    5.7.1    https://github.com/ROCm/MIVisionX/archive/rocm-5.7.1.tar.gz    5.7.0    https://github.com/ROCm/MIVisionX/archive/rocm-5.7.0.tar.gzDeprecated versions:    5.6.1    https://github.com/ROCm/MIVisionX/archive/rocm-5.6.1.tar.gz    5.6.0    https://github.com/ROCm/MIVisionX/archive/rocm-5.6.0.tar.gzVariants:    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    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 ^cmake@3.9:      ipo [false]               false, true          CMake interprocedural optimizationBuild Dependencies:    cmake  ffmpeg  hip           libjpeg-turbo  lmdb      miopen-hip  opencv   protobuf   py-google-api-python-client  py-protobuf  py-pytz        py-wheel  rapidjson  rpp    cxx    gmake   hsa-rocr-dev  llvm-amdgpu    migraphx  ninja       openssl  py-future  py-numpy                     py-pybind11  py-setuptools  python    rocm-coreLink Dependencies:    hip  hsa-rocr-dev  llvm-amdgpu  lmdb  migraphx  miopen-hip  openssl  py-future  py-google-api-python-client  py-numpy  py-pybind11  py-pytz  py-setuptools  py-wheel  rapidjson  rocm-core  rppRun Dependencies:    py-protobufLicenses:    MIT

Installing variants for ROCm components#

The variants listed above indicate that themivisionx package is built bydefault withbuild_type=Release and thehip backend, and without theopencl backend.build_type=Debug andRelWithDebInfo, withopencland withouthip, are also supported.

For example:

spackinstallmivisionxbuild_type=Debug#Backend will be hip since it is the default onespackinstallmivisionx+openclbuild_type=Debug#Backend will be opencl and hip will be disabled as per the conflict defined in recipe
  • spackspec command

    To display the dependency tree, thespackspec command can be used with the same format.

    For example:

    $spackspecmivisionx-   mivisionx@7.0.2~add_tests~asan+hip~ipo build_system=cmake build_type=Release generator=make platform=linux os=ubuntu22.04 target=zen2 %cxx=gcc@11.4.0-       ^cmake@3.31.8~doc+ncurses+ownlibs~qtgui build_system=generic build_type=Release platform=linux os=ubuntu22.04 target=zen2 %c,cxx=gcc@11.4.0-           ^curl@8.15.0~gssapi~ldap~libidn2~librtmp~libssh~libssh2+nghttp2 build_system=autotools libs:=shared,static tls:=openssl platform=linux os=ubuntu22.04 target=zen2 %c,cxx=gcc@11.4.0-               ^nghttp2@1.65.0 build_system=autotools platform=linux os=ubuntu22.04 target=zen2 %c,cxx=gcc@11.4.0...

Creating an environment#

You can create an environment with all the required components of your version.

  1. In the root folder, create a new folder when you can create a.yaml file. This file is used to create an environment.

    mkdir/localscratchcd/localscratchvisample.yaml
  2. Add all the required components in thesample.yaml file. For example:

    spack:concretization:separatelypackages:all:compiler:[gcc@8.5.0]specs:-matrix:-['%gcc@8.5.0^cmake@3.19.7']-[rocm-cmake@7.0.2,rocm-dbgapi@7.0.2,rocm-debug-agent@7.0.2,rocm-gdb@7.0.2,rocminfo@7.0.2,rocm-opencl@7.0.2,rocm-smi-lib@7.0.2,rocm-tensile@7.0.2,rocm-validation-suite@7.0.2,rocprim@7.0.2,rocprofiler-dev@7.0.2,rocrand@7.0.2,rocsolver@7.0.2,rocsparse@7.0.2,rocthrust@7.0.2,roctracer-dev@7.0.2]view:true
  3. Once you’ve created the.yaml file, you can use it to create an environment.

    spackenvcreate-d/localscratch/MyEnvironment/localscratch/sample.yaml
  4. Activate the created environment.

    spackenvactivate/localscratch/MyEnvironment
  5. Before installing, verify that you want all the component versions.

    spackfind# this command will list out all components been in the environment (and 0 installed )
  6. Install all the components in the.yaml file.

    cd/localscratch/MyEnvironmentspackinstall-j50
  7. Check that all components are successfully installed.

    spackfind
  8. 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:

    spackenvdeactivate

Creating and applying a patch before installation#

Spack installs ROCm packages after pulling the source code from GitHub and building it locally. Inorder to build a component with any modification to the source code, you must generate a patch andapply it before the build phase.

To generate a patch and build with the changes:

  1. Stage the source code. For example:

    spackstagehip@7.0.2# (This will pull the 7.0.2 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-7.0.2/spack/var/spack/cache/_source-cache/archive/d8/d8dba8cdf05463afb7879de2833983cafa6a006ba719815a35b96d9b92fc7fc4.tar.gz==> Using cached archive: /data/root/temp/rocm-7.0.2/spack/var/spack/cache/_source-cache/archive/82/829e61a5c54d0c8325d02b0191c0c8254b5740e63b8bfdb05eec9e03d48f7d2c.tar.gz==> Using cached archive: /data/root/temp/rocm-7.0.2/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-7.0.2-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-7.0.2-zo53ondw3tevsr3gmoofbhre7asvis46/spack-src/hip-tests==> Staged hip in /tmp/root/spack-stage/spack-stage-hip-7.0.2-zo53ondw3tevsr3gmoofbhre7asvis46
  2. Change directory tospack-src inside the staged directory.

    /spack$ cd /tmp/root/spack-stage/spack-stage-hip-7.0.2-zo53ondw3tevsr3gmoofbhre7asvis46/tmp/root/spack-stage/spack-stage-hip-7.0.2-zo53ondw3tevsr3gmoofbhre7asvis46$ cd spack-src/
  3. Create a new Git repository.

    /tmp/root/spack-stage/spack-stage-hip-7.0.2-zo53ondw3tevsr3gmoofbhre7asvis46/spack-src$gitinit
  4. Add the entire directory to the repository.

    /tmp/root/spack-stage/spack-stage-hip-7.0.2-zo53ondw3tevsr3gmoofbhre7asvis46/spack-src$gitadd.
  5. Make the required changes to the source code.

    /tmp/root/spack-stage/spack-stage-hip-7.0.2-zo53ondw3tevsr3gmoofbhre7asvis46/spack-src#vihipamd/CMakeLists.txt# Make required changes in the source code
  6. Generate the patch using thegitdiff command.

    diff>/spack/var/spack/repos/builtin/packages/hip/0001-modifications.patch/tmp/root/spack-stage/spack-stage-hip-7.0.2-zo53ondw3tevsr3gmoofbhre7asvis46/spack-src$gitdiff>/spack/var/spack/repos/builtin/packages/hip/0001-modifications.patch
  7. Update the recipe with the patch file name and any conditions you want to apply.

    /tmp/root/spack-stage/spack-stage-hip-7.0.2-zo53ondw3tevsr3gmoofbhre7asvis46/spack-src$spackedithip
  8. Provide the patch file name and the conditions for the patch to be applied in thehip recipe as follows.

    patch("0001-modifications.patch",when="@7.0.2")

    Spack will apply0001-modifications.patch on the 7.0.2 release code before starting thehip build.

  9. 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