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
|
2023-03-15 16:39:30 +00:00
|
|
|
, mako
|
2023-08-04 22:07:22 +00:00
|
|
|
, config
|
|
|
|
, cudaSupport ? config.cudaSupport
|
|
|
|
, cudaPackages ? { }
|
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";
|
2024-01-02 11:29:13 +00:00
|
|
|
format = "setuptools";
|
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 (
|
2022-04-15 01:41:22 +00:00
|
|
|
lib.optionals cudaSupport (with cudaPackages; [ 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
|
2023-03-15 16:39:30 +00:00
|
|
|
mako
|
2020-04-24 23:36:52 +00:00
|
|
|
];
|
|
|
|
|
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;
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|