20 inherit (cudaPackages) cudnn cutensor nccl;
21 outpaths = with cudaPackages; [
22 cuda_cccl # <nv/target>
24 cuda_nvcc # <crt/host_defines.h>
38 cudatoolkit-joined = symlinkJoin {
39 name = "cudatoolkit-joined-${cudaPackages.cudaVersion}";
40 paths = outpaths ++ lib.concatMap (f: lib.map f outpaths) [lib.getLib lib.getDev (lib.getOutput "static") (lib.getOutput "stubs")];
43 buildPythonPackage rec {
46 format = "setuptools";
48 disabled = pythonOlder "3.7";
50 src = fetchFromGitHub {
54 hash = "sha256-vZAtpIZztmsYeJeuq7yl7kgZse2azrIM3efHDmUswJI=";
55 fetchSubmodules = true;
61 "https://github.com/cfhammill/cupy/commit/67526c756e4a0a70f0420bf0e7f081b8a35a8ee5.patch";
62 hash = "sha256-WZgexBdM9J0ep5s+9CGZriVq0ZidCRccox+g0iDDywQ=";
66 # See https://docs.cupy.dev/en/v10.2.0/reference/environment.html. Seting both
67 # CUPY_NUM_BUILD_JOBS and CUPY_NUM_NVCC_THREADS to NIX_BUILD_CORES results in
68 # a small amount of thrashing but it turns out there are a large number of
69 # very short builds and a few extremely long ones, so setting both ends up
70 # working nicely in practice.
72 export CUPY_NUM_BUILD_JOBS="$NIX_BUILD_CORES"
73 export CUPY_NUM_NVCC_THREADS="$NIX_BUILD_CORES"
81 cudaPackages.cuda_nvcc
91 NVCC = "${lib.getExe cudaPackages.cuda_nvcc}"; # FIXME: splicing/buildPackages
92 CUDA_PATH = "${cudatoolkit-joined}";
94 propagatedBuildInputs = [
104 # Won't work with the GPU, whose drivers won't be accessible from the build
109 find $out -type f \( -name '*.so' -or -name '*.so.*' \) | while read lib; do
110 addDriverRunpath "$lib"
114 enableParallelBuilding = true;
117 description = "NumPy-compatible matrix library accelerated by CUDA";
118 homepage = "https://cupy.chainer.org/";
119 changelog = "https://github.com/cupy/cupy/releases/tag/v${version}";
120 license = licenses.mit;
121 platforms = [ "x86_64-linux" ];
122 maintainers = with maintainers; [ hyphon81 ];