16 # , pytorch-image-models
31 inherit (torch) cudaCapabilities cudaPackages cudaSupport;
32 version = "0.0.23.post1";
37 format = "setuptools";
39 disabled = pythonOlder "3.7";
41 src = fetchFromGitHub {
42 owner = "facebookresearch";
44 rev = "refs/tags/v${version}";
45 hash = "sha256-AJXow8MmX4GxtEE2jJJ/ZIBr+3i+uS4cA6vofb390rY=";
46 fetchSubmodules = true;
49 patches = [ ./0001-fix-allow-building-without-git.patch ];
52 cat << EOF > ./xformers/version.py
54 __version__ = "${version}"
57 export MAX_JOBS=$NIX_BUILD_CORES
60 env = lib.attrsets.optionalAttrs cudaSupport {
61 TORCH_CUDA_ARCH_LIST = "${lib.concatStringsSep ";" torch.cudaCapabilities}";
64 stdenv = if cudaSupport then cudaPackages.backendStdenv else stdenv;
66 buildInputs = lib.optionals cudaSupport (
70 cuda_cudart # cuda_runtime_api.h
71 libcusparse # cusparse.h
73 libcublas # cublas_v2.h
74 libcusolver # cusolverDn.h
75 libcurand # curand_kernel.h
82 ] ++ lib.optionals cudaSupport (with cudaPackages; [ cuda_nvcc ]);
84 propagatedBuildInputs = [
89 pythonImportsCheck = [ "xformers" ];
91 # Has broken 0.03 version:
92 # https://github.com/NixOS/nixpkgs/pull/285495#issuecomment-1920730720
93 passthru.skipBulkUpdate = true;
95 dontUseCmakeConfigure = true;
97 # see commented out missing packages
100 nativeCheckInputs = [
118 description = "XFormers: A collection of composable Transformer building blocks";
119 homepage = "https://github.com/facebookresearch/xformers";
120 changelog = "https://github.com/facebookresearch/xformers/blob/${version}/CHANGELOG.md";
121 license = licenses.bsd3;
122 maintainers = with maintainers; [ happysalada ];