2017-11-09 11:26:09 +00:00
|
|
|
{ stdenv
|
2017-09-17 16:02:20 +01:00
|
|
|
, lib
|
2021-09-21 09:05:02 +01:00
|
|
|
, addOpenGLRunpath
|
2017-09-17 16:02:20 +01:00
|
|
|
, buildPythonPackage
|
|
|
|
, fetchFromGitHub
|
|
|
|
, cmake
|
|
|
|
, cython
|
|
|
|
, numpy
|
|
|
|
, six
|
|
|
|
, nose
|
|
|
|
, Mako
|
2022-04-03 10:19:04 +01:00
|
|
|
, cudaSupport ? false, cudaPackages
|
2017-09-17 16:02:20 +01:00
|
|
|
, openclSupport ? true, ocl-icd, clblas
|
2017-11-09 11:26:09 +00:00
|
|
|
}:
|
2017-09-17 16:02:20 +01:00
|
|
|
|
|
|
|
buildPythonPackage rec {
|
2017-11-09 11:26:09 +00:00
|
|
|
pname = "libgpuarray";
|
2021-03-24 17:41:50 +00:00
|
|
|
version = "0.7.6";
|
2017-09-17 16:02:20 +01:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
2017-11-09 11:26:09 +00:00
|
|
|
owner = "Theano";
|
2017-09-17 16:02:20 +01:00
|
|
|
repo = "libgpuarray";
|
|
|
|
rev = "v${version}";
|
2021-03-24 17:41:50 +00:00
|
|
|
sha256 = "0ksil18c9ign4xrv5k323flhvdy6wdxh8szdd3nivv31jc3zsdri";
|
2017-11-09 11:26:09 +00:00
|
|
|
};
|
2017-09-17 16:02:20 +01:00
|
|
|
|
|
|
|
# requires a GPU
|
|
|
|
doCheck = false;
|
|
|
|
|
|
|
|
configurePhase = "cmakeConfigurePhase";
|
|
|
|
|
|
|
|
libraryPath = lib.makeLibraryPath (
|
2022-04-03 10:19:04 +01:00
|
|
|
lib.optionals cudaSupport (with cudaPackages; [ cudatoolkit.lib cudatoolkit.out ])
|
2018-04-15 17:34:45 +01:00
|
|
|
++ lib.optionals openclSupport ([ clblas ] ++ lib.optional (!stdenv.isDarwin) ocl-icd)
|
2017-09-17 16:02:20 +01:00
|
|
|
);
|
|
|
|
|
|
|
|
preBuild = ''
|
|
|
|
make -j$NIX_BUILD_CORES
|
|
|
|
make install
|
|
|
|
|
|
|
|
export NIX_CFLAGS_COMPILE="-L $out/lib -I $out/include $NIX_CFLAGS_COMPILE"
|
|
|
|
|
|
|
|
cd ..
|
2017-11-09 11:26:09 +00:00
|
|
|
'';
|
2017-09-17 16:02:20 +01:00
|
|
|
|
|
|
|
postFixup = ''
|
|
|
|
rm $out/lib/libgpuarray-static.a
|
2021-01-24 00:29:22 +00:00
|
|
|
'' + lib.optionalString (!stdenv.isDarwin) ''
|
2017-09-17 16:02:20 +01:00
|
|
|
function fixRunPath {
|
|
|
|
p=$(patchelf --print-rpath $1)
|
|
|
|
patchelf --set-rpath "$p:$libraryPath" $1
|
|
|
|
}
|
|
|
|
|
|
|
|
fixRunPath $out/lib/libgpuarray.so
|
2021-09-21 09:05:02 +01:00
|
|
|
'' + lib.optionalString cudaSupport ''
|
|
|
|
addOpenGLRunpath $out/lib/libgpuarray.so
|
2017-09-17 16:02:20 +01:00
|
|
|
'';
|
|
|
|
|
|
|
|
propagatedBuildInputs = [
|
|
|
|
numpy
|
|
|
|
six
|
|
|
|
Mako
|
|
|
|
];
|
|
|
|
|
2021-09-21 09:05:02 +01:00
|
|
|
nativeBuildInputs = [
|
|
|
|
cmake
|
|
|
|
] ++ lib.optionals cudaSupport [
|
|
|
|
addOpenGLRunpath
|
|
|
|
];
|
|
|
|
|
2019-03-29 13:18:55 +00:00
|
|
|
|
2017-11-09 11:26:09 +00:00
|
|
|
buildInputs = [
|
|
|
|
cython
|
2017-09-17 16:02:20 +01:00
|
|
|
nose
|
2017-11-09 11:26:09 +00:00
|
|
|
];
|
2017-09-17 16:02:20 +01:00
|
|
|
|
2021-01-11 07:54:33 +00:00
|
|
|
meta = with lib; {
|
2017-09-17 16:02:20 +01:00
|
|
|
homepage = "https://github.com/Theano/libgpuarray";
|
|
|
|
description = "Library to manipulate tensors on GPU.";
|
|
|
|
license = licenses.free;
|
|
|
|
maintainers = with maintainers; [ artuuge ];
|
2018-04-15 17:34:45 +01:00
|
|
|
platforms = platforms.unix;
|
2017-09-17 16:02:20 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|