Using Spack to install ROCm packages
Contents
Using Spack to install ROCm packages#
2025-11-19
15 min read time
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#
To use the Spack package manager, clone the Spack project fromspack/spack.
gitclonehttps://github.com/spack/spack.git
Initialize Spack.
The
setup-env.shscript initializes the Spack environment.cdspack.share/spack/setup-env.shSpack commands are available once the above steps are completed. To list the available commands, use
help.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 |
| 5.6.0 | 7.0.2 |
aqlprofile |
| 7.0.0 | 7.0.2 |
comgr |
| 5.6.0 | 7.0.2 |
Composable Kernel |
| 5.6.0 | 7.0.2 |
devicelibs |
| 5.6.0 | 7.0.2 |
HIP (hip_in_vdi) |
| 5.6.0 | 7.0.2 |
hipBLAS |
| 5.6.0 | 7.0.2 |
hipBLASLt |
| 6.0.0 | 7.0.2 |
HIPCC |
| 5.7.0 | 7.0.2 |
hipCUB |
| 5.6.0 | 7.0.2 |
hipFFT |
| 5.6.0 | 7.0.2 |
hipfort |
| 5.6.0 | 7.0.2 |
HIPIFY |
| 5.6.0 | 7.0.2 |
hipRAND |
| 5.6.0 | 7.0.2 |
hipSOLVER |
| 5.6.0 | 7.0.2 |
hipSPARSE |
| 5.6.0 | 7.0.2 |
hipSPARSELt |
| 6.0.0 | 7.0.2 |
hipTensor |
| 5.7.0 | 7.0.2 |
HIP Tests |
| 6.1.0 | 7.0.2 |
lightning |
| 5.6.0 | 7.0.2 |
MIOpen (HIP) |
| 5.6.0 | 7.0.2 |
MIGraphX |
| 5.6.0 | 7.0.2 |
MIVisionX |
| 5.6.0 | 7.0.2 |
OpenCL |
| 5.6.0 | 7.0.2 |
openmp-extras |
| 5.6.0 | 7.0.2 |
RCCL |
| 5.6.0 | 7.0.2 |
rocAL |
| 6.2.0 | 7.0.2 |
rocALUTION |
| 5.6.0 | 7.0.2 |
rocBLAS |
| 5.6.0 | 7.0.2 |
ROCdbgapi |
| 5.6.0 | 7.0.2 |
rocDecode |
| 6.1.0 | 7.0.2 |
rocFFT |
| 5.6.0 | 7.0.2 |
rocJPEG |
| 6.3.0 | 7.0.2 |
rocm-core |
| 5.6.0 | 7.0.2 |
rocminfo |
| 5.6.0 | 7.0.2 |
rocMLIR |
| 5.4.0 | 7.0.2 |
ROCm Bandwidth Test |
| 5.6.0 | 7.0.2 |
rocm-cmake |
| 5.6.0 | 7.0.2 |
ROCm Compute Profiler |
| 6.3.2 | 7.0.2 |
ROCm Data Center Tool (RDC) |
| 5.6.0 | 7.0.2 |
ROCm Debug Agent |
| 5.6.0 | 7.0.2 |
ROCm Debugger (ROCgdb) |
| 5.6.0 | 7.0.2 |
ROCm Examples |
| 6.2.0 | 7.0.2 |
ROCm SMI Library |
| 5.6.0 | 7.0.2 |
ROCm Systems Profiler |
| 6.3.0 | 7.0.2 |
ROCm Validation Suite |
| 5.6.0 | 7.0.2 |
rocPRIM |
| 5.6.0 | 7.0.2 |
ROCProfiler |
| 5.6.0 | 7.0.2 |
rocprofiler-register |
| 6.1.0 | 7.0.2 |
ROCprofiler-SDK |
| 6.2.4 | 7.0.2 |
rocPyDecode |
| 6.2.0 | 7.0.2 |
rocRAND |
| 5.6.0 | 7.0.2 |
ROCr Runtime |
| 5.6.0 | 7.0.2 |
rocSHMEM |
| 6.4.0 | 7.0.2 |
rocSOLVER |
| 5.6.0 | 7.0.2 |
rocSPARSE |
| 5.6.0 | 7.0.2 |
rocThrust |
| 5.6.0 | 7.0.2 |
ROCTracer |
| 5.6.0 | 7.0.2 |
roctracer-dev-api |
| 5.6.0 | 7.0.2 |
rocWMMA |
| 5.6.0 | 7.0.2 |
ROCm Performance Primitives (RPP) |
| 5.7.0 | 7.0.2 |
Tensile |
| 5.6.0 | 7.0.2 |
TransferBench |
| 6.3.0 | 7.0.2 |
aqlprofile (old) |
| 5.6.0 | 6.4.3 (final) |
clang-ocl |
| 5.6.0 | 6.1.2 (final) |
Omniperf |
| 6.2.0 | 6.3.1 (final) |
Omnitrace |
| rocm-6.2.0 | rocm-6.3.0 (final) |
ROCT Thunk Interface |
| 5.6.0 | 6.2.4 (final) |
Installing ROCm components using Spack#
rocm-cmakeInstall the default variants and the latest version of
rocm-cmake.spackinstallrocm-cmake
To install a specific version of
rocm-cmake, use:spackinstallrocm-cmake@<versionnumber>
For example,
spackinstallrocm-cmake@7.0.2infoThe
infocommand 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
spackspeccommandTo display the dependency tree, the
spackspeccommand 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.
In the root folder, create a new folder when you can create a
.yamlfile. This file is used to create an environment.mkdir/localscratchcd/localscratchvisample.yamlAdd all the required components in the
sample.yamlfile. 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
Once you’ve created the
.yamlfile, you can use it to create an environment.spackenvcreate-d/localscratch/MyEnvironment/localscratch/sample.yaml
Activate the created environment.
spackenvactivate/localscratch/MyEnvironment
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 )Install all the components in the
.yamlfile.cd/localscratch/MyEnvironmentspackinstall-j50
Check that all components are successfully installed.
spackfind
If any modification is made to the
.yamlfile, 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:
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
Change directory to
spack-srcinside 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/
Create a new Git repository.
/tmp/root/spack-stage/spack-stage-hip-7.0.2-zo53ondw3tevsr3gmoofbhre7asvis46/spack-src$gitinit
Add the entire directory to the repository.
/tmp/root/spack-stage/spack-stage-hip-7.0.2-zo53ondw3tevsr3gmoofbhre7asvis46/spack-src$gitadd.
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 codeGenerate the patch using the
gitdiffcommand.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
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
Provide the patch file name and the conditions for the patch to be applied in the
hiprecipe as follows.patch("0001-modifications.patch",when="@7.0.2")
Spack will apply
0001-modifications.patchon the 7.0.2 release code before starting thehipbuild.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