Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions nixos/doc/manual/release-notes/rl-2505.section.md
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,10 @@

- `python3Packages.jaeger-client` was removed because it was deprecated upstream. [OpenTelemetry](https://opentelemetry.io) is the recommended replacement.

- `rocmPackages.rocm-thunk` has been removed and its functionality has been integrated with the ROCm CLR. Use `rocmPackages.clr` instead.

- `rocmPackages.clang-ocl` has been removed. [It was deprecated by AMD in 2023.](https://github.com/ROCm/clang-ocl)

- `nodePackages.meshcommander` has been removed, as the package was deprecated by Intel.

- The default version of `z3` has been updated from 4.8 to 4.13. There are still a few packages that need specific older versions; those will continue to be maintained as long as other packages depend on them but may be removed in the future.
Expand Down
15 changes: 5 additions & 10 deletions pkgs/by-name/ll/llama-cpp/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -152,16 +152,11 @@ effectiveStdenv.mkDerivation (finalAttrs: {
++ optionals cudaSupport [
(cmakeFeature "CMAKE_CUDA_ARCHITECTURES" cudaPackages.flags.cmakeCudaArchitecturesString)
]
++ optionals rocmSupport [
(cmakeFeature "CMAKE_C_COMPILER" "hipcc")
(cmakeFeature "CMAKE_CXX_COMPILER" "hipcc")

# Build all targets supported by rocBLAS. When updating search for TARGET_LIST_ROCM
# in https://github.com/ROCmSoftwarePlatform/rocBLAS/blob/develop/CMakeLists.txt
# and select the line that matches the current nixpkgs version of rocBLAS.
# Should likely use `rocmPackages.clr.gpuTargets`.
"-DAMDGPU_TARGETS=gfx803;gfx900;gfx906:xnack-;gfx908:xnack-;gfx90a:xnack+;gfx90a:xnack-;gfx940;gfx941;gfx942;gfx1010;gfx1012;gfx1030;gfx1100;gfx1101;gfx1102"
]
++ optionals rocmSupport ([
(cmakeFeature "CMAKE_HIP_COMPILER" "${rocmPackages.clr.hipClangPath}/clang++")
# TODO: this should become `clr.gpuTargets` in the future.
(cmakeFeature "CMAKE_HIP_ARCHITECTURES" rocmPackages.rocblas.amdgpu_targets)
])
++ optionals metalSupport [
(cmakeFeature "CMAKE_C_FLAGS" "-D__ARM_FEATURE_DOTPROD=1")
(cmakeBool "LLAMA_METAL_EMBED_LIBRARY" true)
Expand Down
14 changes: 12 additions & 2 deletions pkgs/by-name/ol/ollama/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -72,17 +72,17 @@ let

rocmLibs = [
rocmPackages.clr
rocmPackages.hipblas-common
rocmPackages.hipblas
rocmPackages.rocblas
rocmPackages.rocsolver
rocmPackages.rocsparse
rocmPackages.rocm-device-libs
rocmPackages.rocm-smi
];
rocmClang = linkFarm "rocm-clang" { llvm = rocmPackages.llvm.clang; };
rocmPath = buildEnv {
name = "rocm-path";
paths = rocmLibs ++ [ rocmClang ];
paths = rocmLibs;
};

cudaLibs = [
Expand Down Expand Up @@ -133,6 +133,8 @@ let
goBuild =
if enableCuda then
buildGoModule.override { stdenv = cudaPackages.backendStdenv; }
else if enableRocm then
buildGoModule.override { stdenv = rocmPackages.stdenv; }
else
buildGoModule;
inherit (lib) licenses platforms maintainers;
Expand All @@ -150,6 +152,14 @@ goBuild {
ROCM_PATH = rocmPath;
CLBlast_DIR = "${clblast}/lib/cmake/CLBlast";
HIP_PATH = rocmPath;
CFLAGS = "-Wno-c++17-extensions -I${rocmPath}/include";
CXXFLAGS = "-Wno-c++17-extensions -I${rocmPath}/include";
}
// lib.optionalAttrs (enableRocm && (rocmPackages.clr.localGpuTargets or false)) {

# If rocm CLR is set to build for an exact set of targets reuse that target list,
# otherwise let ollama use its builtin defaults
HIP_ARCHS = lib.concatStringsSep ";" rocmPackages.clr.localGpuTargets;
}
// lib.optionalAttrs enableCuda { CUDA_PATH = cudaPath; };

Expand Down
4 changes: 3 additions & 1 deletion pkgs/by-name/uc/ucx/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,10 @@ let
paths = rocmList;
};

# rocm build fails with gcc stdenv due to unrecognised arg parallel-jobs
stdenv' = if enableRocm then rocmPackages.stdenv else stdenv;
in
stdenv.mkDerivation rec {
stdenv'.mkDerivation rec {
pname = "ucx";
version = "1.18.0";

Expand Down
17 changes: 7 additions & 10 deletions pkgs/development/libraries/science/math/magma/generic.nix
Original file line number Diff line number Diff line change
Expand Up @@ -117,18 +117,11 @@ stdenv.mkDerivation {
"test"
];

patches = lib.optionals (version == "2.9.0") [
# get ROCm version directly
# https://github.com/icl-utk-edu/magma/pull/27
(fetchpatch {
url = "https://github.com/icl-utk-edu/magma/commit/10fe816b763c41099fa1c978a79d6869246671cf.patch";
hash = "sha256-qSY5ACMHyHofJdQKyPqx8sI8GbPD6IZezmCd8qOS5OM=";
})
];

# Fixup for the python test runners
postPatch =
''
# For rocm version script invoked by cmake
patchShebangs tools/
# Fixup for the python test runners
patchShebangs ./testing/run_{tests,summarize}.py
''
+ lib.optionalString (strings.versionOlder version "2.9.0") ''
Expand Down Expand Up @@ -201,6 +194,10 @@ stdenv.mkDerivation {
(strings.cmakeFeature "MIN_ARCH" minArch) # Disarms magma's asserts
]
++ lists.optionals rocmSupport [
# Can be removed once https://github.com/icl-utk-edu/magma/pull/27 is merged
# Can't easily apply the PR as a patch because we rely on the tarball with pregenerated
# hipified files ∴ fetchpatch of the PR will apply cleanly but fail to build
(strings.cmakeFeature "ROCM_CORE" "${effectiveRocmPackages.clr}")
(strings.cmakeFeature "CMAKE_C_COMPILER" "${effectiveRocmPackages.clr}/bin/hipcc")
(strings.cmakeFeature "CMAKE_CXX_COMPILER" "${effectiveRocmPackages.clr}/bin/hipcc")
];
Expand Down
3 changes: 2 additions & 1 deletion pkgs/development/python-modules/accelerate/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,9 @@ buildPythonPackage rec {
# set the environment variable, CC, which conflicts with standard environment
"test_patch_environment_key_exists"
]
++ lib.optionals (pythonAtLeast "3.13") [
++ lib.optionals ((pythonAtLeast "3.13") || (torch.rocmSupport or false)) [
# RuntimeError: Dynamo is not supported on Python 3.13+
# OR torch.compile tests broken on torch 2.5 + rocm
"test_can_unwrap_distributed_compiled_model_keep_torch_compile"
"test_can_unwrap_distributed_compiled_model_remove_torch_compile"
"test_convert_to_fp32"
Expand Down
44 changes: 33 additions & 11 deletions pkgs/development/python-modules/torch/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
symlinkJoin,
which,
pybind11,
pkg-config,
removeReferencesTo,

# Build inputs
Expand Down Expand Up @@ -66,7 +67,13 @@
# (dependencies without cuda support).
# Instead we should rely on overlays and nixpkgsFun.
# (@SomeoneSerge)
_tritonEffective ? if cudaSupport then triton-cuda else triton,
_tritonEffective ?
if cudaSupport then
triton-cuda
else if rocmSupport then
rocmPackages.triton
else
triton,
triton-cuda,

# Unit tests
Expand All @@ -92,7 +99,7 @@

# ROCm dependencies
rocmSupport ? config.rocmSupport,
rocmPackages_5,
rocmPackages,
gpuTargets ? [ ],

vulkanSupport ? false,
Expand All @@ -112,8 +119,6 @@ let

triton = throw "python3Packages.torch: use _tritonEffective instead of triton to avoid divergence";

rocmPackages = rocmPackages_5;

setBool = v: if v then "1" else "0";

# https://github.com/pytorch/pytorch/blob/v2.4.0/torch/utils/cpp_extension.py#L1953
Expand Down Expand Up @@ -181,7 +186,7 @@ let
clr
rccl
miopen
miopengemm
aotriton
rocrand
rocblas
rocsparse
Expand All @@ -193,10 +198,12 @@ let
rocfft
rocsolver
hipfft
hiprand
hipsolver
hipblas-common
hipblas
hipblaslt
rocminfo
rocm-thunk
rocm-comgr
rocm-device-libs
rocm-runtime
Expand Down Expand Up @@ -226,8 +233,6 @@ let
# In particular, this triggered warnings from cuda's `aliases.nix`
"Magma cudaPackages does not match cudaPackages" =
cudaSupport && (effectiveMagma.cudaPackages.cudaVersion != cudaPackages.cudaVersion);
"Rocm support is currently broken because `rocmPackages.hipblaslt` is unpackaged. (2024-06-09)" =
rocmSupport;
};

unroll-src = writeShellScript "unroll-src" ''
Expand Down Expand Up @@ -294,6 +299,11 @@ buildPythonPackage rec {

# annotations (3.7), print_function (3.0), with_statement (2.6) are all supported
sed -i -e "/from __future__ import/d" **.py
substituteInPlace third_party/NNPACK/CMakeLists.txt \
--replace-fail "PYTHONPATH=" 'PYTHONPATH=$ENV{PYTHONPATH}:'
# flag from cmakeFlags doesn't work, not clear why
# setting it at the top of NNPACK's own CMakeLists does
sed -i '2s;^;set(PYTHON_SIX_SOURCE_DIR ${six.src})\n;' third_party/NNPACK/CMakeLists.txt
''
+ lib.optionalString rocmSupport ''
# https://github.com/facebookincubator/gloo/pull/297
Expand Down Expand Up @@ -366,6 +376,10 @@ buildPythonPackage rec {
# We only do an imports check, so do not build tests either.
BUILD_TEST = setBool false;

# ninja hook doesn't automatically turn on ninja
# because pytorch setup.py is responsible for this
CMAKE_GENERATOR = "Ninja";

# Unlike MKL, oneDNN (née MKLDNN) is FOSS, so we enable support for
# it by default. PyTorch currently uses its own vendored version
# of oneDNN through Intel iDeep.
Expand All @@ -376,14 +390,15 @@ buildPythonPackage rec {
# Also avoids pytorch exporting the headers of pybind11
USE_SYSTEM_PYBIND11 = true;

# NB technical debt: building without NNPACK as workaround for missing `six`
USE_NNPACK = 0;
# Multicore CPU convnet support
USE_NNPACK = 1;

# Explicitly enable MPS for Darwin
USE_MPS = setBool stdenv.hostPlatform.isDarwin;

cmakeFlags =
[
(lib.cmakeFeature "PYTHON_SIX_SOURCE_DIR" "${six.src}")
# (lib.cmakeBool "CMAKE_FIND_DEBUG_MODE" true)
(lib.cmakeFeature "CUDAToolkit_VERSION" cudaPackages.cudaVersion)
]
Expand Down Expand Up @@ -441,6 +456,9 @@ buildPythonPackage rec {
}
// lib.optionalAttrs vulkanSupport {
VULKAN_SDK = shaderc.bin;
}
// lib.optionalAttrs rocmSupport {
AOTRITON_INSTALLED_PREFIX = "${rocmPackages.aotriton}";
};

nativeBuildInputs =
Expand All @@ -449,6 +467,7 @@ buildPythonPackage rec {
which
ninja
pybind11
pkg-config
removeReferencesTo
]
++ lib.optionals cudaSupport (
Expand Down Expand Up @@ -502,7 +521,10 @@ buildPythonPackage rec {
]
++ lib.optionals tritonSupport [ _tritonEffective ]
++ lib.optionals MPISupport [ mpi ]
++ lib.optionals rocmSupport [ rocmtoolkit_joined ];
++ lib.optionals rocmSupport [
rocmtoolkit_joined
rocmPackages.clr # Added separately so setup hook applies
];

pythonRelaxDeps = [
"sympy"
Expand Down
3 changes: 1 addition & 2 deletions pkgs/development/python-modules/torchaudio/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ let
clr
rccl
miopen
miopengemm
rocrand
rocblas
rocsparse
Expand All @@ -49,9 +48,9 @@ let
rocsolver
hipfft
hipsolver
hipblas-common
hipblas
rocminfo
rocm-thunk
rocm-comgr
rocm-device-libs
rocm-runtime
Expand Down
89 changes: 89 additions & 0 deletions pkgs/development/rocm-modules/6/amdsmi/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
{
lib,
stdenv,
fetchFromGitHub,
fetchpatch,
rocmUpdateScript,
cmake,
pkg-config,
libdrm,
wrapPython,
autoPatchelfHook,
}:

let
esmi_ib_src = fetchFromGitHub {
owner = "amd";
repo = "esmi_ib_library";
rev = "esmi_pkg_ver-3.0.3";
hash = "sha256-q0w5c5c+CpXkklmSyfzc+sbkt4cHNxscGJA3AXwvHxQ=";
};
in
stdenv.mkDerivation (finalAttrs: {
pname = "amdsmi";
version = "6.3.3";
src = fetchFromGitHub {
owner = "rocm";
repo = "amdsmi";
rev = "rocm-${finalAttrs.version}";
hash = "sha256-hrPqd4ZWqzTG7JRfVwc1SZx6TNS0Q/LFg8yDxrM3mPo=";
};

postPatch = ''
substituteInPlace goamdsmi_shim/CMakeLists.txt \
--replace-fail "amd_smi)" ${"'"}''${AMD_SMI_TARGET})' \
--replace-fail 'target_link_libraries(''${GOAMDSMI_SHIM_TARGET} -L' '#'

# Manually unpack esmi_ib_src and add amd_hsmp.h so execute-process git clone doesn't run
cp -rf --no-preserve=mode ${esmi_ib_src} ./esmi_ib_library
mkdir -p ./esmi_ib_library/include/asm
cp ./include/amd_smi/impl/amd_hsmp.h ./esmi_ib_library/include/asm/amd_hsmp.h
'';

patches = [
# Fix ld.lld undefined reference: drmGetVersion
(fetchpatch {
url = "https://github.com/ROCm/amdsmi/commit/c3864bf6171970d86dc50fd23f06377736823997.patch";
hash = "sha256-zRG1tBD8sIQCWdKfCbXC/Z/6d6NTrRYvRpddPWdM4j8=";
})
];

nativeBuildInputs = [
cmake
pkg-config
wrapPython
autoPatchelfHook
];

buildInputs = [
libdrm
];

cmakeFlags = [
# Manually define CMAKE_INSTALL_<DIR>
# See: https://github.com/NixOS/nixpkgs/pull/197838
"-DCMAKE_INSTALL_BINDIR=bin"
"-DCMAKE_INSTALL_LIBDIR=lib"
"-DCMAKE_INSTALL_INCLUDEDIR=include"
];

postInstall = ''
wrapPythonProgramsIn $out
rm $out/bin/amd-smi
ln -sf $out/libexec/amdsmi_cli/amdsmi_cli.py $out/bin/amd-smi
'';

passthru.updateScript = rocmUpdateScript {
name = finalAttrs.pname;
inherit (finalAttrs.src) owner;
inherit (finalAttrs.src) repo;
};

meta = with lib; {
description = "System management interface for AMD GPUs supported by ROCm";
homepage = "https://github.com/ROCm/rocm_smi_lib";
license = with licenses; [ mit ];
maintainers = with maintainers; [ lovesegfault ] ++ teams.rocm.members;
platforms = [ "x86_64-linux" ];
};
})
Loading