diff options
Diffstat (limited to 'pkgs/development/python-modules/bitsandbytes/default.nix')
-rw-r--r-- | pkgs/development/python-modules/bitsandbytes/default.nix | 86 |
1 files changed, 44 insertions, 42 deletions
diff --git a/pkgs/development/python-modules/bitsandbytes/default.nix b/pkgs/development/python-modules/bitsandbytes/default.nix index 189b8a9c6c27c..9bfc4a89784fe 100644 --- a/pkgs/development/python-modules/bitsandbytes/default.nix +++ b/pkgs/development/python-modules/bitsandbytes/default.nix @@ -1,18 +1,19 @@ -{ lib -, buildPythonPackage -, fetchFromGitHub -, python -, pythonOlder -, setuptools -, wheel -, torch -, scipy -, symlinkJoin +{ + lib, + buildPythonPackage, + fetchFromGitHub, + python, + pythonOlder, + setuptools, + wheel, + torch, + scipy, + symlinkJoin, }: let pname = "bitsandbytes"; - version = "0.42.0"; + version = "0.43.1"; inherit (torch) cudaCapabilities cudaPackages cudaSupport; inherit (cudaPackages) backendStdenv cudaVersion; @@ -29,17 +30,19 @@ let cuda-native-redist = symlinkJoin { name = "cuda-native-redist-${cudaVersion}"; - paths = with cudaPackages; [ - cuda_cudart # cuda_runtime.h cuda_runtime_api.h - cuda_nvcc - ] ++ cuda-common-redist; + paths = + with cudaPackages; + [ + cuda_cudart # cuda_runtime.h cuda_runtime_api.h + cuda_nvcc + ] + ++ cuda-common-redist; }; cuda-redist = symlinkJoin { name = "cuda-redist-${cudaVersion}"; paths = cuda-common-redist; }; - in buildPythonPackage { inherit pname version; @@ -51,49 +54,48 @@ buildPythonPackage { owner = "TimDettmers"; repo = "bitsandbytes"; rev = "refs/tags/${version}"; - hash = "sha256-PZxsFJ6WpfeQqRQrRRBZfZfNY6/TfJFLBeknX24OXcU="; + hash = "sha256-GFbFKPdV96DXPA+PZO4h0zdBclN670fb0PGv4QPHWHU="; }; - postPatch = '' - substituteInPlace Makefile --replace "/usr/bin/g++" "g++" --replace "lib64" "lib" - substituteInPlace bitsandbytes/cuda_setup/main.py \ - --replace "binary_path = package_dir / self.binary_name" \ - "binary_path = Path('$out/${python.sitePackages}/${pname}')/self.binary_name" - '' + lib.optionalString torch.cudaSupport '' - substituteInPlace bitsandbytes/cuda_setup/main.py \ - --replace "/usr/local/cuda/lib64" "${cuda-native-redist}/lib" - ''; + postPatch = + '' + substituteInPlace Makefile --replace "/usr/bin/g++" "g++" --replace "lib64" "lib" + substituteInPlace bitsandbytes/cuda_setup/main.py \ + --replace "binary_path = package_dir / self.binary_name" \ + "binary_path = Path('$out/${python.sitePackages}/${pname}')/self.binary_name" + '' + + lib.optionalString torch.cudaSupport '' + substituteInPlace bitsandbytes/cuda_setup/main.py \ + --replace "/usr/local/cuda/lib64" "${cuda-native-redist}/lib" + ''; CUDA_HOME = "${cuda-native-redist}"; - preBuild = if torch.cudaSupport then - with torch.cudaPackages; - let cudaVersion = lib.concatStrings (lib.splitVersion torch.cudaPackages.cudaMajorMinorVersion); in - ''make CUDA_VERSION=${cudaVersion} cuda${cudaMajorVersion}x'' - else - ''make CUDA_VERSION=CPU cpuonly''; + preBuild = + if torch.cudaSupport then + with torch.cudaPackages; + let + cudaVersion = lib.concatStrings (lib.splitVersion torch.cudaPackages.cudaMajorMinorVersion); + in + ''make CUDA_VERSION=${cudaVersion} cuda${cudaMajorVersion}x'' + else + ''make CUDA_VERSION=CPU cpuonly''; nativeBuildInputs = [ setuptools wheel - ] ++ lib.optionals torch.cudaSupport [ - cuda-native-redist - ]; + ] ++ lib.optionals torch.cudaSupport [ cuda-native-redist ]; - buildInputs = lib.optionals torch.cudaSupport [ - cuda-redist - ]; + buildInputs = lib.optionals torch.cudaSupport [ cuda-redist ]; propagatedBuildInputs = [ scipy torch ]; - doCheck = false; # tests require CUDA and also GPU access + doCheck = false; # tests require CUDA and also GPU access - pythonImportsCheck = [ - "bitsandbytes" - ]; + pythonImportsCheck = [ "bitsandbytes" ]; meta = with lib; { description = "8-bit CUDA functions for PyTorch"; |