Eliminate uses of `config.cudaSupport or false` and alike, since the option is now declared in config.nix with a default value fd .nix -t f -x sed 's/config\.cudaSupport or false, cudaPackages [?] [{][}]/config.cudaSupport, cudaPackages ? { }/' '{}' -i fd .nix -t f -x sed 's/config\.cudaSupport or false/config.cudaSupport/' '{}' -i fd .nix -t f -x sed 's/cudaSupport = pkgs.config.cudaSupport/inherit (pkgs.config) cudaSupport/' '{}' -i fd .nix -t f -x sed 's/cudaSupport = config.cudaSupport/inherit (config) cudaSupport/' '{}' -i
88 lines
1.7 KiB
Nix
88 lines
1.7 KiB
Nix
{ stdenv
|
|
, lib
|
|
, addOpenGLRunpath
|
|
, buildPythonPackage
|
|
, fetchFromGitHub
|
|
, cmake
|
|
, cython
|
|
, numpy
|
|
, six
|
|
, nose
|
|
, mako
|
|
, config
|
|
, cudaSupport ? config.cudaSupport
|
|
, cudaPackages ? { }
|
|
, openclSupport ? true, ocl-icd, clblas
|
|
}:
|
|
|
|
buildPythonPackage rec {
|
|
pname = "libgpuarray";
|
|
version = "0.7.6";
|
|
|
|
src = fetchFromGitHub {
|
|
owner = "Theano";
|
|
repo = "libgpuarray";
|
|
rev = "v${version}";
|
|
sha256 = "0ksil18c9ign4xrv5k323flhvdy6wdxh8szdd3nivv31jc3zsdri";
|
|
};
|
|
|
|
# requires a GPU
|
|
doCheck = false;
|
|
|
|
configurePhase = "cmakeConfigurePhase";
|
|
|
|
libraryPath = lib.makeLibraryPath (
|
|
lib.optionals cudaSupport (with cudaPackages; [ cudatoolkit.lib cudatoolkit.out ])
|
|
++ 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
|
|
'' + lib.optionalString (!stdenv.isDarwin) ''
|
|
function fixRunPath {
|
|
p=$(patchelf --print-rpath $1)
|
|
patchelf --set-rpath "$p:$libraryPath" $1
|
|
}
|
|
|
|
fixRunPath $out/lib/libgpuarray.so
|
|
'' + lib.optionalString cudaSupport ''
|
|
addOpenGLRunpath $out/lib/libgpuarray.so
|
|
'';
|
|
|
|
propagatedBuildInputs = [
|
|
numpy
|
|
six
|
|
mako
|
|
];
|
|
|
|
nativeBuildInputs = [
|
|
cmake
|
|
] ++ lib.optionals cudaSupport [
|
|
addOpenGLRunpath
|
|
];
|
|
|
|
|
|
buildInputs = [
|
|
cython
|
|
nose
|
|
];
|
|
|
|
meta = with lib; {
|
|
homepage = "https://github.com/Theano/libgpuarray";
|
|
description = "Library to manipulate tensors on GPU.";
|
|
license = licenses.free;
|
|
maintainers = with maintainers; [ artuuge ];
|
|
platforms = platforms.unix;
|
|
};
|
|
|
|
}
|