From e6f88a9a824ad8a34bf9d501aa45b0883a4a80c9 Mon Sep 17 00:00:00 2001 From: Madoura Date: Thu, 5 Oct 2023 16:58:02 -0500 Subject: rocm-related: fixup for ROCm 5.7.0 blender: fixup for ROCm 5.7.0 opensycl: fixup for ROCm 5.7.0 magma: fixup for ROCm 5.7.0 torch: fixup for ROCm 5.7.0 cp2k: fixup for ROCm 5.7.0 sirius: fixup for ROCm 5.7.0 spfft: fixup for ROCm 5.7.0 spla: fixup for ROCm 5.7.0 --- pkgs/applications/misc/blender/default.nix | 6 +++--- .../science/chemistry/cp2k/default.nix | 16 ++++++++------- pkgs/by-name/si/sirius/package.nix | 11 ++++++----- pkgs/by-name/sp/spfft/package.nix | 13 ++++++------ pkgs/by-name/sp/spla/package.nix | 9 +++++---- pkgs/development/compilers/opensycl/default.nix | 10 ++++------ .../libraries/science/math/magma/generic.nix | 19 ++++++++---------- pkgs/development/python-modules/torch/default.nix | 23 ++++++++++------------ pkgs/top-level/all-packages.nix | 9 ++------- pkgs/top-level/python-packages.nix | 1 - 10 files changed, 54 insertions(+), 63 deletions(-) diff --git a/pkgs/applications/misc/blender/default.nix b/pkgs/applications/misc/blender/default.nix index 0b368ef1b31..00bbcdafff1 100644 --- a/pkgs/applications/misc/blender/default.nix +++ b/pkgs/applications/misc/blender/default.nix @@ -6,7 +6,7 @@ , zlib, zstd, fftw, opensubdiv, freetype, jemalloc, ocl-icd, addOpenGLRunpath , jackaudioSupport ? false, libjack2 , cudaSupport ? config.cudaSupport, cudaPackages ? { } -, hipSupport ? false, hip # comes with a significantly larger closure size +, hipSupport ? false, rocmPackages # comes with a significantly larger closure size , colladaSupport ? true, opencollada , spaceNavSupport ? stdenv.isLinux, libspnav , makeWrapper @@ -103,8 +103,8 @@ stdenv.mkDerivation (finalAttrs: rec { substituteInPlace extern/clew/src/clew.c --replace '"libOpenCL.so"' '"${ocl-icd}/lib/libOpenCL.so"' '') + (lib.optionalString hipSupport '' - substituteInPlace extern/hipew/src/hipew.c --replace '"/opt/rocm/hip/lib/libamdhip64.so"' '"${hip}/lib/libamdhip64.so"' - substituteInPlace extern/hipew/src/hipew.c --replace '"opt/rocm/hip/bin"' '"${hip}/bin"' + substituteInPlace extern/hipew/src/hipew.c --replace '"/opt/rocm/hip/lib/libamdhip64.so"' '"${rocmPackages.clr}/lib/libamdhip64.so"' + substituteInPlace extern/hipew/src/hipew.c --replace '"opt/rocm/hip/bin"' '"${rocmPackages.clr}/bin"' ''); cmakeFlags = diff --git a/pkgs/applications/science/chemistry/cp2k/default.nix b/pkgs/applications/science/chemistry/cp2k/default.nix index 052d791c0bb..bb306fa322f 100644 --- a/pkgs/applications/science/chemistry/cp2k/default.nix +++ b/pkgs/applications/science/chemistry/cp2k/default.nix @@ -37,11 +37,7 @@ # and for Nvidia see https://github.com/cp2k/cp2k/blob/master/INSTALL.md#2i-cuda-optional-improved-performance-on-gpu-systems , gpuVersion ? "Mi100" , gpuArch ? "gfx908" -, rocm-core -, hip -, hipblas -, hipfft -, rocblas +, rocmPackages }: assert builtins.elem gpuBackend [ "none" "cuda" "rocm" ]; @@ -86,7 +82,13 @@ stdenv.mkDerivation rec { ] ++ lib.optional enableElpa elpa ++ lib.optional (gpuBackend == "cuda") cudaPackages.cudatoolkit - ++ lib.optional (gpuBackend == "rocm") [hip rocm-core hipblas hipfft rocblas] + ++ lib.optional (gpuBackend == "rocm") [ + rocmPackages.clr + rocmPackages.rocm-core + rocmPackages.hipblas + rocmPackages.hipfft + rocmPackages.rocblas + ] ; propagatedBuildInputs = [ mpi ]; @@ -126,7 +128,7 @@ stdenv.mkDerivation rec { ${lib.strings.optionalString (gpuBackend == "rocm") '' GPUVER = ${gpuVersion} OFFLOAD_CC = hipcc - OFFLOAD_FLAGS = -fopenmp -m64 -pthread -fPIC -D__GRID_HIP -O2 --offload-arch=${gpuArch} --rocm-path=${rocm-core} + OFFLOAD_FLAGS = -fopenmp -m64 -pthread -fPIC -D__GRID_HIP -O2 --offload-arch=${gpuArch} --rocm-path=${rocmPackages.rocm-core} OFFLOAD_TARGET = hip CXX = mpicxx CXXFLAGS = -std=c++11 -fopenmp -D__HIP_PLATFORM_AMD__ diff --git a/pkgs/by-name/si/sirius/package.nix b/pkgs/by-name/si/sirius/package.nix index 05d049a7d45..2af3c28de92 100644 --- a/pkgs/by-name/si/sirius/package.nix +++ b/pkgs/by-name/si/sirius/package.nix @@ -23,8 +23,7 @@ , llvmPackages , gpuBackend ? "none" , cudaPackages -, hip -, rocblas +, rocmPackages }: assert builtins.elem gpuBackend [ "none" "cuda" "rocm" ]; @@ -67,8 +66,10 @@ stdenv.mkDerivation rec { libvdwxc ] ++ lib.optional (gpuBackend == "cuda") cudaPackages.cudatoolkit - ++ lib.optionals (gpuBackend == "rocm") [ hip rocblas ] - ++ lib.optional stdenv.isDarwin llvmPackages.openmp + ++ lib.optionals (gpuBackend == "rocm") [ + rocmPackages.clr + rocmPackages.rocblas + ] ++ lib.optional stdenv.isDarwin llvmPackages.openmp ; propagatedBuildInputs = [ mpi ]; @@ -87,7 +88,7 @@ stdenv.mkDerivation rec { ] ++ lib.optionals (gpuBackend == "rocm") [ "-DUSE_ROCM=ON" - "-DHIP_ROOT_DIR=${hip}" + "-DHIP_ROOT_DIR=${rocmPackages.clr}" ]; doCheck = true; diff --git a/pkgs/by-name/sp/spfft/package.nix b/pkgs/by-name/sp/spfft/package.nix index dcc43ccd244..72ae473d14a 100644 --- a/pkgs/by-name/sp/spfft/package.nix +++ b/pkgs/by-name/sp/spfft/package.nix @@ -8,9 +8,7 @@ , llvmPackages , gpuBackend ? "none" , cudaPackages -, hip -, rocfft -, hipfft +, rocmPackages }: assert builtins.elem gpuBackend [ "none" "cuda" "rocm" ]; @@ -35,8 +33,11 @@ stdenv.mkDerivation rec { fftw ] ++ lib.optional (gpuBackend == "cuda") cudaPackages.cudatoolkit - ++ lib.optionals (gpuBackend == "rocm") [ hip rocfft hipfft ] - ++ lib.optional stdenv.isDarwin llvmPackages.openmp + ++ lib.optionals (gpuBackend == "rocm") [ + rocmPackages.clr + rocmPackages.rocfft + rocmPackages.hipfft + ] ++ lib.optional stdenv.isDarwin llvmPackages.openmp ; propagatedBuildInputs = [ mpi ]; @@ -53,7 +54,7 @@ stdenv.mkDerivation rec { ++ lib.optional (gpuBackend == "cuda") "-DSPFFT_GPU_BACKEND=CUDA" ++ lib.optionals (gpuBackend == "rocm") [ "-DSPFFT_GPU_BACKEND=ROCM" - "-DHIP_ROOT_DIR=${hip}" + "-DHIP_ROOT_DIR=${rocmPackages.clr}" ]; diff --git a/pkgs/by-name/sp/spla/package.nix b/pkgs/by-name/sp/spla/package.nix index 3143fbeb731..1f8abde4b72 100644 --- a/pkgs/by-name/sp/spla/package.nix +++ b/pkgs/by-name/sp/spla/package.nix @@ -8,8 +8,7 @@ , llvmPackages , gpuBackend ? "none" , cudaPackages -, hip -, rocblas +, rocmPackages }: assert builtins.elem gpuBackend [ "none" "cuda" "rocm" ]; @@ -39,8 +38,10 @@ stdenv.mkDerivation rec { blas ] ++ lib.optional (gpuBackend == "cuda") cudaPackages.cudatoolkit - ++ lib.optionals (gpuBackend == "rocm") [ hip rocblas rocblas ] - ++ lib.optional stdenv.isDarwin llvmPackages.openmp + ++ lib.optionals (gpuBackend == "rocm") [ + rocmPackages.clr + rocmPackages.rocblas + ] ++ lib.optional stdenv.isDarwin llvmPackages.openmp ; propagatedBuildInputs = [ mpi ]; diff --git a/pkgs/development/compilers/opensycl/default.nix b/pkgs/development/compilers/opensycl/default.nix index d6f11798f19..995b21330a9 100644 --- a/pkgs/development/compilers/opensycl/default.nix +++ b/pkgs/development/compilers/opensycl/default.nix @@ -2,15 +2,13 @@ , fetchFromGitHub , llvmPackages_15 , lld_15 -, rocm-device-libs , python3 -, rocm-runtime , cmake , boost , libxml2 , libffi , makeWrapper -, hip +, rocmPackages , rocmSupport ? false }: let @@ -40,8 +38,8 @@ stdenv.mkDerivation rec { llvmPackages_15.libclang.dev llvmPackages_15.llvm ] ++ lib.optionals rocmSupport [ - hip - rocm-runtime + rocmPackages.clr + rocmPackages.rocm-runtime ]; # opensycl makes use of clangs internal headers. Its cmake does not successfully discover them automatically on nixos, so we supply the path manually @@ -55,7 +53,7 @@ stdenv.mkDerivation rec { --add-flags "-L${llvmPackages_15.openmp}/lib" \ --add-flags "-I${llvmPackages_15.openmp.dev}/include" \ '' + lib.optionalString rocmSupport '' - --add-flags "--rocm-device-lib-path=${rocm-device-libs}/amdgcn/bitcode" + --add-flags "--rocm-device-lib-path=${rocmPackages.rocm-device-libs}/amdgcn/bitcode" ''; meta = with lib; { diff --git a/pkgs/development/libraries/science/math/magma/generic.nix b/pkgs/development/libraries/science/math/magma/generic.nix index b3753a63339..e9712ffb62a 100644 --- a/pkgs/development/libraries/science/math/magma/generic.nix +++ b/pkgs/development/libraries/science/math/magma/generic.nix @@ -18,15 +18,12 @@ , gfortran , cudaCapabilities ? cudaPackages.cudaFlags.cudaCapabilities , gpuTargets ? [ ] # Non-CUDA targets, that is HIP -, hip -, hipblas -, hipsparse +, rocmPackages , lapack , lib , libpthreadstubs , magmaRelease , ninja -, openmp , rocmSupport ? false , static ? false , stdenv @@ -47,7 +44,7 @@ let # NOTE: The hip.gpuTargets are prefixed with "gfx" instead of "sm" like cudaFlags.realArches. # For some reason, Magma's CMakeLists.txt file does not handle the "gfx" prefix, so we must # remove it. - rocmArches = lists.map (x: strings.removePrefix "gfx" x) hip.gpuTargets; + rocmArches = lists.map (x: strings.removePrefix "gfx" x) rocmPackages.clr.gpuTargets; supportedRocmArches = lists.intersectLists rocmArches supportedGpuTargets; unsupportedRocmArches = lists.subtractLists supportedRocmArches rocmArches; @@ -125,10 +122,10 @@ stdenv.mkDerivation { ] ++ lists.optionals (strings.versionAtLeast cudaVersion "11.8") [ cuda_profiler_api.dev # ]) ++ lists.optionals rocmSupport [ - hip - hipblas - hipsparse - openmp + rocmPackages.clr + rocmPackages.hipblas + rocmPackages.hipsparse + rocmPackages.llvm.openmp ]; cmakeFlags = [ @@ -142,8 +139,8 @@ stdenv.mkDerivation { "-DCMAKE_CXX_COMPILER=${backendStdenv.cc}/bin/c++" "-DMAGMA_ENABLE_CUDA=ON" ] ++ lists.optionals rocmSupport [ - "-DCMAKE_C_COMPILER=${hip}/bin/hipcc" - "-DCMAKE_CXX_COMPILER=${hip}/bin/hipcc" + "-DCMAKE_C_COMPILER=${rocmPackages.clr}/bin/hipcc" + "-DCMAKE_CXX_COMPILER=${rocmPackages.clr}/bin/hipcc" "-DMAGMA_ENABLE_HIP=ON" ]; diff --git a/pkgs/development/python-modules/torch/default.nix b/pkgs/development/python-modules/torch/default.nix index f9f6e377b13..c9c400b57bd 100644 --- a/pkgs/development/python-modules/torch/default.nix +++ b/pkgs/development/python-modules/torch/default.nix @@ -43,11 +43,7 @@ # ROCm dependencies rocmSupport ? false, - gpuTargets ? [ ], - openmp, rocm-core, hip, rccl, miopen, miopengemm, rocrand, rocblas, - rocfft, rocsparse, hipsparse, rocthrust, rocprim, hipcub, roctracer, - rocsolver, hipfft, hipsolver, hipblas, rocminfo, rocm-thunk, rocm-comgr, - rocm-device-libs, rocm-runtime, rocm-opencl-runtime, hipify + gpuTargets ? [ ], rocmPackages }: let @@ -89,7 +85,7 @@ let else if cudaSupport then gpuArchWarner supportedCudaCapabilities unsupportedCudaCapabilities else if rocmSupport then - hip.gpuTargets + rocmPackages.clr.gpuTargets else throw "No GPU targets specified" ); @@ -97,12 +93,13 @@ let rocmtoolkit_joined = symlinkJoin { name = "rocm-merged"; - paths = [ - rocm-core hip rccl miopen miopengemm rocrand rocblas - rocfft rocsparse hipsparse rocthrust rocprim hipcub - roctracer rocfft rocsolver hipfft hipsolver hipblas + paths = with rocmPackages; [ + rocm-core clr rccl miopen miopengemm rocrand rocblas + rocsparse hipsparse rocthrust rocprim hipcub + roctracer # Unfree at the moment due to hsa-amd-aqlprofile hard dependency in rocprofiler + rocfft rocsolver hipfft hipsolver hipblas rocminfo rocm-thunk rocm-comgr rocm-device-libs - rocm-runtime rocm-opencl-runtime hipify + rocm-runtime clr.icd hipify ]; }; @@ -170,7 +167,7 @@ in buildPythonPackage rec { # Strangely, this is never set in cmake substituteInPlace cmake/public/LoadHIP.cmake \ --replace "set(ROCM_PATH \$ENV{ROCM_PATH})" \ - "set(ROCM_PATH \$ENV{ROCM_PATH})''\nset(ROCM_VERSION ${lib.concatStrings (lib.intersperse "0" (lib.splitString "." hip.version))})" + "set(ROCM_PATH \$ENV{ROCM_PATH})''\nset(ROCM_VERSION ${lib.concatStrings (lib.intersperse "0" (lib.splitString "." rocmPackages.clr.version))})" '' # Detection of NCCL version doesn't work particularly well when using the static binary. + lib.optionalString cudaSupport '' @@ -323,7 +320,7 @@ in buildPythonPackage rec { ] ++ lists.optionals (strings.versionAtLeast cudaVersion "11.8") [ cuda_profiler_api.dev # ]) - ++ lib.optionals rocmSupport [ openmp ] + ++ lib.optionals rocmSupport [ rocmPackages.llvm.openmp ] ++ lib.optionals (cudaSupport || rocmSupport) [ magma ] ++ lib.optionals stdenv.isLinux [ numactl ] ++ lib.optionals stdenv.isDarwin [ Accelerate CoreServices libobjc ]; diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index d365df0eb0f..a62783c951a 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -30690,7 +30690,6 @@ with pkgs; # LLVM 11 crashes when compiling GHOST_SystemCocoa.mm stdenv = if stdenv.isDarwin then llvmPackages_10.stdenv else stdenv; inherit (darwin.apple_sdk.frameworks) Cocoa CoreGraphics ForceFeedback OpenAL OpenGL; - inherit (rocmPackages) hip; }; blender-with-packages = callPackage ../applications/misc/blender/wrapper.nix { }; @@ -39262,10 +39261,7 @@ with pkgs; lie = callPackage ../applications/science/math/LiE { }; - inherit (callPackage ../development/libraries/science/math/magma { - inherit (rocmPackages.llvm) openmp; - inherit (rocmPackages) hip hipblas hipsparse; - }) magma magma_2_7_2 magma_2_6_2; + inherit (callPackage ../development/libraries/science/math/magma { }) magma magma_2_7_2 magma_2_6_2; magma-cuda = magma.override { cudaSupport = true; @@ -39276,8 +39272,7 @@ with pkgs; static = true; }; - # TODO:AMD won't compile with anything newer than 2.6.2 -- it fails at the linking stage. - magma-hip = magma_2_6_2.override { + magma-hip = magma.override { cudaSupport = false; rocmSupport = true; }; diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index c0857bf850f..16751903fe5 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -13904,7 +13904,6 @@ self: super: with self; { else pkgs.magma; inherit (pkgs.darwin.apple_sdk.frameworks) Accelerate CoreServices; inherit (pkgs.darwin) libobjc; - inherit (pkgs.rocmPackages.llvm) openmp; }; torch-bin = callPackage ../development/python-modules/torch/bin.nix { -- cgit 1.4.1