|
| 1 | +# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. |
| 2 | +# SPDX-License-Identifier: Apache-2.0 |
| 3 | + |
| 4 | +# Local override of the builtin spack `cudss` package. Upstream only lists the |
| 5 | +# CUDA 12 redistributables together with `depends_on("cuda@12:")`, so on a |
| 6 | +# CUDA 13 toolchain spack hands out the CUDA 12 binary, which then fails to load |
| 7 | +# `libcudart.so.12` at runtime. Here each cuDSS build is bound to its matching |
| 8 | +# CUDA major version, so the concretizer selects the redistributable that |
| 9 | +# matches the CUDA in the DAG (CUDA 12 -> cuda12 build, CUDA 13 -> cuda13 build). |
| 10 | +# Remove once the upstream spack recipe ships the CUDA 13 redistributables. |
| 11 | + |
| 12 | +import platform |
| 13 | + |
| 14 | +from spack_repo.builtin.build_systems.generic import Package |
| 15 | + |
| 16 | +from spack.package import * |
| 17 | + |
| 18 | +_url = ( |
| 19 | + "https://developer.download.nvidia.com/compute/cudss/redist/libcudss/" |
| 20 | + "linux-{arch}/libcudss-linux-{arch}-{ver}_cuda{cuda}-archive.tar.xz" |
| 21 | +) |
| 22 | + |
| 23 | + |
| 24 | +class Cudss(Package): |
| 25 | + """NVIDIA cuDSS is a GPU-accelerated Direct Sparse Solver library for |
| 26 | + solving linear systems with very sparse matrices. This local override adds |
| 27 | + the CUDA 13 redistributables alongside the upstream CUDA 12 ones.""" |
| 28 | + |
| 29 | + homepage = "https://developer.nvidia.com/cudss" |
| 30 | + |
| 31 | + if platform.machine() == "x86_64": |
| 32 | + # CUDA 12 build (default; matches the upstream recipe). |
| 33 | + version( |
| 34 | + "0.7.1", |
| 35 | + sha256="946571d9ea164f948e402dd97a14541cb90fbec800336cfa7ae644af5937632f", |
| 36 | + url=_url.format(arch="x86_64", ver="0.7.1.4", cuda="12"), |
| 37 | + preferred=True, |
| 38 | + ) |
| 39 | + # CUDA 13 build. |
| 40 | + version( |
| 41 | + "0.7.1-cuda13", |
| 42 | + sha256="84b34ebe7fad40ec10f2aab2957a63b6070bd8ce16e3ada3e6bcac7317256347", |
| 43 | + url=_url.format(arch="x86_64", ver="0.7.1.4", cuda="13"), |
| 44 | + ) |
| 45 | + elif platform.machine() == "aarch64": |
| 46 | + # CUDA 12 build (upstream only ships aarch64 for CUDA 12 so far). |
| 47 | + version( |
| 48 | + "0.7.1", |
| 49 | + sha256="f283c31b6badf4a5277014295705eac8e6e28f27de30d746719ea1cef7a750b8", |
| 50 | + url=_url.format(arch="aarch64", ver="0.7.1.4", cuda="12"), |
| 51 | + preferred=True, |
| 52 | + ) |
| 53 | + |
| 54 | + # Bind each redistributable to its matching CUDA major so the concretizer |
| 55 | + # never pairs a cuda12 binary with a CUDA 13 toolchain (or vice versa). |
| 56 | + depends_on("cuda@12.0:12", when="@0.7.1") |
| 57 | + depends_on("cuda@13.0:13", when="@0.7.1-cuda13") |
| 58 | + |
| 59 | + def install(self, spec, prefix): |
| 60 | + install_tree(".", prefix) |
0 commit comments