nixpkgs/pkgs/development/rocm-modules/5/migraphx/default.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

172 lines
4 KiB
Nix
Raw Normal View History

2022-12-20 12:09:46 +01:00
{ lib
, stdenv
, fetchFromGitHub
, rocmUpdateScript
, pkg-config
, cmake
, rocm-cmake
, clr
2022-12-20 12:09:46 +01:00
, clang-tools-extra
, openmp
, rocblas
, rocmlir
, composable_kernel
2022-12-20 12:09:46 +01:00
, miopengemm
, miopen
, protobuf
, half
, nlohmann_json
, msgpack
, sqlite
2023-06-14 18:10:20 +02:00
, oneDNN_2
2022-12-20 12:09:46 +01:00
, blaze
, cppcheck
, rocm-device-libs
, texliveSmall
2022-12-20 12:09:46 +01:00
, doxygen
, sphinx
, docutils
, ghostscript
, python3Packages
, buildDocs ? false
, buildTests ? false
}:
let
latex = lib.optionalAttrs buildDocs (texliveSmall.withPackages (ps: with ps; [
2022-12-20 12:09:46 +01:00
latexmk
tex-gyre
fncychap
wrapfig
capt-of
framed
needspace
tabulary
varwidth
titlesec
epstopdf
]));
2022-12-20 12:09:46 +01:00
in stdenv.mkDerivation (finalAttrs: {
pname = "migraphx";
rocmPackages: 5.7.0 -> 5.7.1 rocmPackages.clang-ocl: 5.7.0 -> 5.7.1 rocmPackages.hip-common: 5.7.0 -> 5.7.1 rocmPackages.half: 5.7.0 -> 5.7.1 rocmPackages.hipcc: 5.7.0 -> 5.7.1 rocmPackages.hipcub: 5.7.0 -> 5.7.1 rocmPackages.hipfft: 5.7.0 -> 5.7.1 rocmPackages.composable_kernel: 5.7.0 -> 5.7.1 rocmPackages.hipblas: 5.7.0 -> 5.7.1 rocmPackages.hiprand: 5.7.0 -> 5.7.1 rocmPackages.hipsolver: 5.7.0 -> 5.7.1 rocmPackages.hipsparse: 5.7.0 -> 5.7.1 rocmPackages.llvm.llvm: 5.7.0 -> 5.7.1 rocmPackages.migraphx: 5.7.0 -> 5.7.1 rocmPackages.hipfort: 5.7.0 -> 5.7.1 rocmPackages.miopen: 5.7.0 -> 5.7.1 rocmPackages.mivisionx: 5.7.0 -> 5.7.1 rocmPackages.hipify: 5.7.0 -> 5.7.1 rocmPackages.rocalution: 5.7.0 -> 5.7.1 rocmPackages.rocblas: 5.7.0 -> 5.7.1 rocmPackages.rdc: 5.7.0 -> 5.7.1 rocmPackages.rocfft: 5.7.0 -> 5.7.1 rocmPackages.rocgdb: 5.7.0 -> 5.7.1 rocmPackages.rccl: 5.7.0 -> 5.7.1 rocmPackages.rocm-comgr: 5.7.0 -> 5.7.1 rocmPackages.rocm-cmake: 5.7.0 -> 5.7.1 rocmPackages.rocm-device-libs: 5.7.0 -> 5.7.1 rocmPackages.rocm-runtime: 5.7.0 -> 5.7.1 rocmPackages.rocm-smi: 5.7.0 -> 5.7.1 rocmPackages.rocm-thunk: 5.7.0 -> 5.7.1 rocmPackages.rocminfo: 5.7.0 -> 5.7.1 rocmPackages.rocmlir: 5.7.0 -> 5.7.1 rocmPackages.rocdbgapi: 5.7.0 -> 5.7.1 rocmPackages.rocprim: 5.7.0 -> 5.7.1 rocmPackages.rocr-debug-agent: 5.7.0 -> 5.7.1 rocmPackages.rocsolver: 5.7.0 -> 5.7.1 rocmPackages.rocm-docs-core: 0.25.0 -> 0.26.0 rocmPackages.rocthrust: 5.7.0 -> 5.7.1 rocmPackages.rocprofiler: 5.7.0 -> 5.7.1 rocmPackages.roctracer: 5.7.0 -> 5.7.1 rocmPackages.rocsparse: 5.7.0 -> 5.7.1 rocmPackages.rpp: 5.7.0 -> 5.7.1 rocmPackages.tensile: 5.7.0 -> 5.7.1 rocmPackages.rocwmma: 5.7.0 -> 5.7.1 rocmPackages.clr: 5.7.0 -> 5.7.1
2023-10-17 07:53:19 +02:00
version = "5.7.1";
2022-12-20 12:09:46 +01:00
outputs = [
"out"
] ++ lib.optionals buildDocs [
"doc"
] ++ lib.optionals buildTests [
"test"
];
src = fetchFromGitHub {
owner = "ROCmSoftwarePlatform";
repo = "AMDMIGraphX";
rev = "rocm-${finalAttrs.version}";
rocmPackages: 5.7.0 -> 5.7.1 rocmPackages.clang-ocl: 5.7.0 -> 5.7.1 rocmPackages.hip-common: 5.7.0 -> 5.7.1 rocmPackages.half: 5.7.0 -> 5.7.1 rocmPackages.hipcc: 5.7.0 -> 5.7.1 rocmPackages.hipcub: 5.7.0 -> 5.7.1 rocmPackages.hipfft: 5.7.0 -> 5.7.1 rocmPackages.composable_kernel: 5.7.0 -> 5.7.1 rocmPackages.hipblas: 5.7.0 -> 5.7.1 rocmPackages.hiprand: 5.7.0 -> 5.7.1 rocmPackages.hipsolver: 5.7.0 -> 5.7.1 rocmPackages.hipsparse: 5.7.0 -> 5.7.1 rocmPackages.llvm.llvm: 5.7.0 -> 5.7.1 rocmPackages.migraphx: 5.7.0 -> 5.7.1 rocmPackages.hipfort: 5.7.0 -> 5.7.1 rocmPackages.miopen: 5.7.0 -> 5.7.1 rocmPackages.mivisionx: 5.7.0 -> 5.7.1 rocmPackages.hipify: 5.7.0 -> 5.7.1 rocmPackages.rocalution: 5.7.0 -> 5.7.1 rocmPackages.rocblas: 5.7.0 -> 5.7.1 rocmPackages.rdc: 5.7.0 -> 5.7.1 rocmPackages.rocfft: 5.7.0 -> 5.7.1 rocmPackages.rocgdb: 5.7.0 -> 5.7.1 rocmPackages.rccl: 5.7.0 -> 5.7.1 rocmPackages.rocm-comgr: 5.7.0 -> 5.7.1 rocmPackages.rocm-cmake: 5.7.0 -> 5.7.1 rocmPackages.rocm-device-libs: 5.7.0 -> 5.7.1 rocmPackages.rocm-runtime: 5.7.0 -> 5.7.1 rocmPackages.rocm-smi: 5.7.0 -> 5.7.1 rocmPackages.rocm-thunk: 5.7.0 -> 5.7.1 rocmPackages.rocminfo: 5.7.0 -> 5.7.1 rocmPackages.rocmlir: 5.7.0 -> 5.7.1 rocmPackages.rocdbgapi: 5.7.0 -> 5.7.1 rocmPackages.rocprim: 5.7.0 -> 5.7.1 rocmPackages.rocr-debug-agent: 5.7.0 -> 5.7.1 rocmPackages.rocsolver: 5.7.0 -> 5.7.1 rocmPackages.rocm-docs-core: 0.25.0 -> 0.26.0 rocmPackages.rocthrust: 5.7.0 -> 5.7.1 rocmPackages.rocprofiler: 5.7.0 -> 5.7.1 rocmPackages.roctracer: 5.7.0 -> 5.7.1 rocmPackages.rocsparse: 5.7.0 -> 5.7.1 rocmPackages.rpp: 5.7.0 -> 5.7.1 rocmPackages.tensile: 5.7.0 -> 5.7.1 rocmPackages.rocwmma: 5.7.0 -> 5.7.1 rocmPackages.clr: 5.7.0 -> 5.7.1
2023-10-17 07:53:19 +02:00
hash = "sha256-lg3pxHBpwqxBvdOQgE44YKLuumhkVF6b3Xx4+cw7jNQ=";
2022-12-20 12:09:46 +01:00
};
nativeBuildInputs = [
pkg-config
cmake
rocm-cmake
clr
2022-12-20 12:09:46 +01:00
clang-tools-extra
python3Packages.python
] ++ lib.optionals buildDocs [
latex
doxygen
sphinx
docutils
ghostscript
python3Packages.sphinx-rtd-theme
python3Packages.breathe
];
buildInputs = [
openmp
rocblas
rocmlir
composable_kernel
2022-12-20 12:09:46 +01:00
miopengemm
miopen
protobuf
half
nlohmann_json
msgpack
sqlite
2023-06-14 18:10:20 +02:00
oneDNN_2
2022-12-20 12:09:46 +01:00
blaze
cppcheck
2022-12-20 12:09:46 +01:00
python3Packages.pybind11
python3Packages.onnx
];
cmakeFlags = [
"-DMIGRAPHX_ENABLE_GPU=ON"
2022-12-20 12:09:46 +01:00
"-DMIGRAPHX_ENABLE_CPU=ON"
"-DMIGRAPHX_ENABLE_FPGA=ON"
"-DMIGRAPHX_ENABLE_MLIR=OFF" # LLVM or rocMLIR mismatch?
2022-12-20 12:09:46 +01:00
# 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"
];
postPatch = ''
# We need to not use hipcc and define the CXXFLAGS manually due to `undefined hidden symbol: tensorflow:: ...`
export CXXFLAGS+="--rocm-path=${clr} --rocm-device-lib-path=${rocm-device-libs}/amdgcn/bitcode"
2022-12-20 12:09:46 +01:00
patchShebangs tools
# `error: '__clang_hip_runtime_wrapper.h' file not found [clang-diagnostic-error]`
substituteInPlace CMakeLists.txt \
--replace "set(MIGRAPHX_TIDY_ERRORS ALL)" ""
# JIT library was removed from composable_kernel...
# https://github.com/ROCmSoftwarePlatform/composable_kernel/issues/782
2022-12-20 12:09:46 +01:00
substituteInPlace src/targets/gpu/CMakeLists.txt \
--replace " COMPONENTS jit_library" "" \
--replace " composable_kernel::jit_library" "" \
--replace "if(WIN32)" "if(TRUE)"
2022-12-20 12:09:46 +01:00
'' + lib.optionalString (!buildDocs) ''
substituteInPlace CMakeLists.txt \
--replace "add_subdirectory(doc)" ""
'' + lib.optionalString (!buildTests) ''
substituteInPlace CMakeLists.txt \
--replace "add_subdirectory(test)" ""
'';
# Unfortunately, it seems like we have to call make on this manually
preInstall = lib.optionalString buildDocs ''
export HOME=$(mktemp -d)
make -j$NIX_BUILD_CORES doc
cd ../doc/pdf
make -j$NIX_BUILD_CORES
cd -
'';
postInstall = lib.optionalString buildDocs ''
mv ../doc/html $out/share/doc/migraphx
mv ../doc/pdf/MIGraphX.pdf $out/share/doc/migraphx
'' + lib.optionalString buildTests ''
mkdir -p $test/bin
mv bin/test_* $test/bin
patchelf $test/bin/test_* --shrink-rpath --allowed-rpath-prefixes "$NIX_STORE"
2022-12-20 12:09:46 +01:00
'';
passthru.updateScript = rocmUpdateScript {
name = finalAttrs.pname;
owner = finalAttrs.src.owner;
repo = finalAttrs.src.repo;
};
meta = with lib; {
description = "AMD's graph optimization engine";
homepage = "https://github.com/ROCmSoftwarePlatform/AMDMIGraphX";
license = with licenses; [ mit ];
maintainers = teams.rocm.members;
2023-01-18 09:25:46 +01:00
platforms = platforms.linux;
broken = versions.minor finalAttrs.version != versions.minor stdenv.cc.version;
2022-12-20 12:09:46 +01:00
};
})