2021-02-05 17:12:51 +00:00
|
|
|
{ lib, buildPythonPackage
|
2021-03-20 04:20:00 +00:00
|
|
|
, fetchPypi, isPy3k, cython
|
|
|
|
, fastrlock, numpy, six, wheel, pytestCheckHook, mock, setuptools
|
2021-03-19 17:17:44 +00:00
|
|
|
, cudatoolkit, cudnn, cutensor, nccl
|
2021-03-20 04:20:00 +00:00
|
|
|
, addOpenGLRunpath
|
2020-04-24 23:36:52 +00:00
|
|
|
}:
|
|
|
|
|
2022-04-03 18:54:34 +00:00
|
|
|
assert cudnn.cudatoolkit == cudatoolkit;
|
|
|
|
assert cutensor.cudatoolkit == cudatoolkit;
|
|
|
|
assert nccl.cudatoolkit == cudatoolkit;
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
buildPythonPackage rec {
|
|
|
|
pname = "cupy";
|
2022-03-05 16:20:37 +00:00
|
|
|
version = "10.2.0";
|
2020-11-06 00:33:48 +00:00
|
|
|
disabled = !isPy3k;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
src = fetchPypi {
|
|
|
|
inherit pname version;
|
2022-03-05 16:20:37 +00:00
|
|
|
sha256 = "sha256-5ovvA76QGOsOnVztMfDgLerks5nJrKR08rLc+ArmWA8=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2022-04-03 18:54:34 +00:00
|
|
|
# See https://docs.cupy.dev/en/v10.2.0/reference/environment.html. Seting both
|
|
|
|
# CUPY_NUM_BUILD_JOBS and CUPY_NUM_NVCC_THREADS to NIX_BUILD_CORES results in
|
|
|
|
# a small amount of thrashing but it turns out there are a large number of
|
|
|
|
# very short builds and a few extremely long ones, so setting both ends up
|
|
|
|
# working nicely in practice.
|
2020-04-24 23:36:52 +00:00
|
|
|
preConfigure = ''
|
2021-03-20 04:20:00 +00:00
|
|
|
export CUDA_PATH=${cudatoolkit}
|
2022-04-03 18:54:34 +00:00
|
|
|
export CUPY_NUM_BUILD_JOBS="$NIX_BUILD_CORES"
|
|
|
|
export CUPY_NUM_NVCC_THREADS="$NIX_BUILD_CORES"
|
2020-09-25 04:45:31 +00:00
|
|
|
'';
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-03-20 04:20:00 +00:00
|
|
|
nativeBuildInputs = [
|
|
|
|
addOpenGLRunpath
|
|
|
|
cython
|
|
|
|
];
|
|
|
|
|
|
|
|
LDFLAGS = "-L${cudatoolkit}/lib/stubs";
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
propagatedBuildInputs = [
|
|
|
|
cudatoolkit
|
|
|
|
cudnn
|
2021-03-19 17:17:44 +00:00
|
|
|
cutensor
|
2020-04-24 23:36:52 +00:00
|
|
|
nccl
|
|
|
|
fastrlock
|
|
|
|
numpy
|
|
|
|
six
|
|
|
|
setuptools
|
|
|
|
wheel
|
|
|
|
];
|
|
|
|
|
2021-03-20 04:20:00 +00:00
|
|
|
checkInputs = [
|
|
|
|
pytestCheckHook
|
|
|
|
mock
|
|
|
|
];
|
|
|
|
|
|
|
|
# Won't work with the GPU, whose drivers won't be accessible from the build
|
|
|
|
# sandbox
|
|
|
|
doCheck = false;
|
|
|
|
|
|
|
|
postFixup = ''
|
|
|
|
find $out -type f \( -name '*.so' -or -name '*.so.*' \) | while read lib; do
|
|
|
|
addOpenGLRunpath "$lib"
|
|
|
|
done
|
|
|
|
'';
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
enableParallelBuilding = true;
|
|
|
|
|
2021-01-15 22:18:51 +00:00
|
|
|
meta = with lib; {
|
2020-04-24 23:36:52 +00:00
|
|
|
description = "A NumPy-compatible matrix library accelerated by CUDA";
|
|
|
|
homepage = "https://cupy.chainer.org/";
|
|
|
|
license = licenses.mit;
|
|
|
|
platforms = [ "x86_64-linux" ];
|
|
|
|
maintainers = with maintainers; [ hyphon81 ];
|
|
|
|
};
|
|
|
|
}
|