python311Packages.torch: choose magma at the expression level
...instead of at the callPackage site. Addresses https://github.com/NixOS/nixpkgs/issues/268736
This commit is contained in:
parent
98405dd2bd
commit
395b7cc35b
4 changed files with 26 additions and 21 deletions
|
@ -589,6 +589,9 @@ The module update takes care of the new config syntax and the data itself (user
|
||||||
|
|
||||||
- `python3.pkgs.flitBuildHook` has been removed. Use `flit-core` and `format = "pyproject"` instead.
|
- `python3.pkgs.flitBuildHook` has been removed. Use `flit-core` and `format = "pyproject"` instead.
|
||||||
|
|
||||||
|
- Now `magma` defaults to `magma-hip` instead of `magma-cuda`. It also
|
||||||
|
respects the `config.cudaSupport` and `config.rocmSupport` options.
|
||||||
|
|
||||||
- The `extend` function of `llvmPackages` has been removed due it coming from the `tools` attrset thus only extending the `tool` attrset. A possible replacement is to construct the set from `libraries` and `tools`, or patch nixpkgs.
|
- The `extend` function of `llvmPackages` has been removed due it coming from the `tools` attrset thus only extending the `tool` attrset. A possible replacement is to construct the set from `libraries` and `tools`, or patch nixpkgs.
|
||||||
|
|
||||||
- The `qemu-vm.nix` module now supports disabling overriding `fileSystems` with
|
- The `qemu-vm.nix` module now supports disabling overriding `fileSystems` with
|
||||||
|
|
|
@ -8,12 +8,7 @@
|
||||||
{ blas
|
{ blas
|
||||||
, cmake
|
, cmake
|
||||||
, cudaPackages
|
, cudaPackages
|
||||||
# FIXME: cuda being unfree means ofborg won't eval "magma".
|
, cudaSupport ? config.cudaSupport
|
||||||
# respecting config.cudaSupport -> false by default
|
|
||||||
# -> ofborg eval -> throws "no GPU targets specified".
|
|
||||||
# Probably should delete everything but "magma-cuda" and "magma-hip"
|
|
||||||
# from all-packages.nix
|
|
||||||
, cudaSupport ? true
|
|
||||||
, fetchurl
|
, fetchurl
|
||||||
, gfortran
|
, gfortran
|
||||||
, cudaCapabilities ? cudaPackages.cudaFlags.cudaCapabilities
|
, cudaCapabilities ? cudaPackages.cudaFlags.cudaCapabilities
|
||||||
|
@ -25,7 +20,9 @@
|
||||||
, magmaRelease
|
, magmaRelease
|
||||||
, ninja
|
, ninja
|
||||||
, config
|
, config
|
||||||
, rocmSupport ? config.rocmSupport
|
# At least one back-end has to be enabled,
|
||||||
|
# and we can't default to CUDA since it's unfree
|
||||||
|
, rocmSupport ? !cudaSupport
|
||||||
, static ? false
|
, static ? false
|
||||||
, stdenv
|
, stdenv
|
||||||
, symlinkJoin
|
, symlinkJoin
|
||||||
|
@ -133,6 +130,8 @@ stdenv.mkDerivation {
|
||||||
|
|
||||||
cmakeFlags = [
|
cmakeFlags = [
|
||||||
"-DGPU_TARGET=${gpuTargetString}"
|
"-DGPU_TARGET=${gpuTargetString}"
|
||||||
|
(lib.cmakeBool "MAGMA_ENABLE_CUDA" cudaSupport)
|
||||||
|
(lib.cmakeBool "MAGMA_ENABLE_HIP" rocmSupport)
|
||||||
] ++ lists.optionals static [
|
] ++ lists.optionals static [
|
||||||
"-DBUILD_SHARED_LIBS=OFF"
|
"-DBUILD_SHARED_LIBS=OFF"
|
||||||
] ++ lists.optionals cudaSupport [
|
] ++ lists.optionals cudaSupport [
|
||||||
|
@ -140,11 +139,9 @@ stdenv.mkDerivation {
|
||||||
"-DMIN_ARCH=${minArch}" # Disarms magma's asserts
|
"-DMIN_ARCH=${minArch}" # Disarms magma's asserts
|
||||||
"-DCMAKE_C_COMPILER=${backendStdenv.cc}/bin/cc"
|
"-DCMAKE_C_COMPILER=${backendStdenv.cc}/bin/cc"
|
||||||
"-DCMAKE_CXX_COMPILER=${backendStdenv.cc}/bin/c++"
|
"-DCMAKE_CXX_COMPILER=${backendStdenv.cc}/bin/c++"
|
||||||
"-DMAGMA_ENABLE_CUDA=ON"
|
|
||||||
] ++ lists.optionals rocmSupport [
|
] ++ lists.optionals rocmSupport [
|
||||||
"-DCMAKE_C_COMPILER=${rocmPackages.clr}/bin/hipcc"
|
"-DCMAKE_C_COMPILER=${rocmPackages.clr}/bin/hipcc"
|
||||||
"-DCMAKE_CXX_COMPILER=${rocmPackages.clr}/bin/hipcc"
|
"-DCMAKE_CXX_COMPILER=${rocmPackages.clr}/bin/hipcc"
|
||||||
"-DMAGMA_ENABLE_HIP=ON"
|
|
||||||
];
|
];
|
||||||
|
|
||||||
buildFlags = [
|
buildFlags = [
|
||||||
|
@ -155,7 +152,7 @@ stdenv.mkDerivation {
|
||||||
doCheck = false;
|
doCheck = false;
|
||||||
|
|
||||||
passthru = {
|
passthru = {
|
||||||
inherit cudaPackages cudaSupport;
|
inherit cudaPackages cudaSupport rocmSupport gpuTargets;
|
||||||
};
|
};
|
||||||
|
|
||||||
meta = with lib; {
|
meta = with lib; {
|
||||||
|
@ -164,7 +161,11 @@ stdenv.mkDerivation {
|
||||||
homepage = "http://icl.cs.utk.edu/magma/index.html";
|
homepage = "http://icl.cs.utk.edu/magma/index.html";
|
||||||
platforms = platforms.unix;
|
platforms = platforms.unix;
|
||||||
maintainers = with maintainers; [ connorbaker ];
|
maintainers = with maintainers; [ connorbaker ];
|
||||||
# CUDA and ROCm are mutually exclusive
|
|
||||||
broken = cudaSupport && rocmSupport || cudaSupport && strings.versionOlder cudaVersion "9";
|
# Cf. https://bitbucket.org/icl/magma/src/fcfe5aa61c1a4c664b36a73ebabbdbab82765e9f/CMakeLists.txt#lines-20
|
||||||
|
broken =
|
||||||
|
!(cudaSupport || rocmSupport) # At least one back-end enabled
|
||||||
|
|| (cudaSupport && rocmSupport) # Mutually exclusive
|
||||||
|
|| (cudaSupport && strings.versionOlder cudaVersion "9");
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,12 @@
|
||||||
{ stdenv, lib, fetchFromGitHub, fetchpatch, buildPythonPackage, python,
|
{ stdenv, lib, fetchFromGitHub, fetchpatch, buildPythonPackage, python,
|
||||||
config, cudaSupport ? config.cudaSupport, cudaPackages, magma,
|
config, cudaSupport ? config.cudaSupport, cudaPackages,
|
||||||
|
effectiveMagma ?
|
||||||
|
if cudaSupport then magma-cuda-static
|
||||||
|
else if rocmSupport then magma-hip
|
||||||
|
else magma,
|
||||||
|
magma,
|
||||||
|
magma-hip,
|
||||||
|
magma-cuda-static,
|
||||||
useSystemNccl ? true,
|
useSystemNccl ? true,
|
||||||
MPISupport ? false, mpi,
|
MPISupport ? false, mpi,
|
||||||
buildDocs ? false,
|
buildDocs ? false,
|
||||||
|
@ -115,7 +122,7 @@ let
|
||||||
"CUDA is not targeting Linux" = cudaSupport && !stdenv.isLinux;
|
"CUDA is not targeting Linux" = cudaSupport && !stdenv.isLinux;
|
||||||
"Unsupported CUDA version" = cudaSupport && !(builtins.elem cudaPackages.cudaMajorVersion [ "11" "12" ]);
|
"Unsupported CUDA version" = cudaSupport && !(builtins.elem cudaPackages.cudaMajorVersion [ "11" "12" ]);
|
||||||
"MPI cudatoolkit does not match cudaPackages.cudatoolkit" = MPISupport && cudaSupport && (mpi.cudatoolkit != cudaPackages.cudatoolkit);
|
"MPI cudatoolkit does not match cudaPackages.cudatoolkit" = MPISupport && cudaSupport && (mpi.cudatoolkit != cudaPackages.cudatoolkit);
|
||||||
"Magma cudaPackages does not match cudaPackages" = cudaSupport && (magma.cudaPackages != cudaPackages);
|
"Magma cudaPackages does not match cudaPackages" = cudaSupport && (effectiveMagma.cudaPackages != cudaPackages);
|
||||||
};
|
};
|
||||||
in buildPythonPackage rec {
|
in buildPythonPackage rec {
|
||||||
pname = "torch";
|
pname = "torch";
|
||||||
|
@ -359,7 +366,7 @@ in buildPythonPackage rec {
|
||||||
cuda_profiler_api.dev # <cuda_profiler_api.h>
|
cuda_profiler_api.dev # <cuda_profiler_api.h>
|
||||||
])
|
])
|
||||||
++ lib.optionals rocmSupport [ rocmPackages.llvm.openmp ]
|
++ lib.optionals rocmSupport [ rocmPackages.llvm.openmp ]
|
||||||
++ lib.optionals (cudaSupport || rocmSupport) [ magma ]
|
++ lib.optionals (cudaSupport || rocmSupport) [ effectiveMagma ]
|
||||||
++ lib.optionals stdenv.isLinux [ numactl ]
|
++ lib.optionals stdenv.isLinux [ numactl ]
|
||||||
++ lib.optionals stdenv.isDarwin [ Accelerate CoreServices libobjc ];
|
++ lib.optionals stdenv.isDarwin [ Accelerate CoreServices libobjc ];
|
||||||
|
|
||||||
|
|
|
@ -14121,10 +14121,6 @@ self: super: with self; {
|
||||||
toposort = callPackage ../development/python-modules/toposort { };
|
toposort = callPackage ../development/python-modules/toposort { };
|
||||||
|
|
||||||
torch = callPackage ../development/python-modules/torch {
|
torch = callPackage ../development/python-modules/torch {
|
||||||
magma =
|
|
||||||
if pkgs.config.cudaSupport
|
|
||||||
then pkgs.magma-cuda-static
|
|
||||||
else pkgs.magma;
|
|
||||||
inherit (pkgs.darwin.apple_sdk.frameworks) Accelerate CoreServices;
|
inherit (pkgs.darwin.apple_sdk.frameworks) Accelerate CoreServices;
|
||||||
inherit (pkgs.darwin) libobjc;
|
inherit (pkgs.darwin) libobjc;
|
||||||
};
|
};
|
||||||
|
@ -14134,7 +14130,6 @@ self: super: with self; {
|
||||||
};
|
};
|
||||||
|
|
||||||
torchWithCuda = self.torch.override {
|
torchWithCuda = self.torch.override {
|
||||||
magma = pkgs.magma-cuda-static;
|
|
||||||
openai-triton = self.openai-triton-cuda;
|
openai-triton = self.openai-triton-cuda;
|
||||||
cudaSupport = true;
|
cudaSupport = true;
|
||||||
rocmSupport = false;
|
rocmSupport = false;
|
||||||
|
@ -14145,7 +14140,6 @@ self: super: with self; {
|
||||||
};
|
};
|
||||||
|
|
||||||
torchWithRocm = self.torch.override {
|
torchWithRocm = self.torch.override {
|
||||||
magma = pkgs.magma-hip;
|
|
||||||
openai-triton = self.openai-triton-no-cuda;
|
openai-triton = self.openai-triton-no-cuda;
|
||||||
rocmSupport = true;
|
rocmSupport = true;
|
||||||
cudaSupport = false;
|
cudaSupport = false;
|
||||||
|
|
Loading…
Reference in a new issue