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