17 # , pytorch-image-models
32 inherit (torch) cudaCapabilities cudaPackages cudaSupport;
33 version = "0.0.28.post3";
40 disabled = pythonOlder "3.9";
42 src = fetchFromGitHub {
43 owner = "facebookresearch";
45 rev = "refs/tags/v${version}";
46 hash = "sha256-23tnhCHK+Z0No8fqZxkgDFp2VIgXZR4jpM+pkb/vvmw=";
47 fetchSubmodules = true;
50 patches = [ ./0001-fix-allow-building-without-git.patch ];
52 build-system = [ setuptools ];
55 cat << EOF > ./xformers/version.py
57 __version__ = "${version}"
60 export MAX_JOBS=$NIX_BUILD_CORES
63 env = lib.attrsets.optionalAttrs cudaSupport {
64 TORCH_CUDA_ARCH_LIST = "${lib.concatStringsSep ";" torch.cudaCapabilities}";
67 stdenv = if cudaSupport then cudaPackages.backendStdenv else stdenv;
69 buildInputs = lib.optionals cudaSupport (
73 cuda_cudart # cuda_runtime_api.h
74 libcusparse # cusparse.h
76 libcublas # cublas_v2.h
77 libcusolver # cusolverDn.h
78 libcurand # curand_kernel.h
85 ] ++ lib.optionals cudaSupport (with cudaPackages; [ cuda_nvcc ]);
92 pythonImportsCheck = [ "xformers" ];
94 # Has broken 0.03 version:
95 # https://github.com/NixOS/nixpkgs/pull/285495#issuecomment-1920730720
96 passthru.skipBulkUpdate = true;
98 dontUseCmakeConfigure = true;
100 # see commented out missing packages
103 nativeCheckInputs = [
121 description = "Collection of composable Transformer building blocks";
122 homepage = "https://github.com/facebookresearch/xformers";
123 changelog = "https://github.com/facebookresearch/xformers/blob/${version}/CHANGELOG.md";
124 license = licenses.bsd3;
125 maintainers = with maintainers; [ happysalada ];