1{ stdenv
2, lib
3, buildPythonPackage
4, fetchFromGitHub
5, cmake
6, cython
7, numpy
8, six
9, nose
10, Mako
11, cudaSupport ? false, cudatoolkit , nvidia_x11
12, openclSupport ? true, ocl-icd, clblas
13}:
14
15assert cudaSupport -> nvidia_x11 != null
16 && cudatoolkit != null;
17
18buildPythonPackage rec {
19 pname = "libgpuarray";
20 version = "0.7.5";
21
22 src = fetchFromGitHub {
23 owner = "Theano";
24 repo = "libgpuarray";
25 rev = "v${version}";
26 sha256 = "0zkdwjq3k6ciiyf8y5w663fbsnmzhgy27yvpxfhkpxazw9vg3l5v";
27 };
28
29 # requires a GPU
30 doCheck = false;
31
32 configurePhase = "cmakeConfigurePhase";
33
34 libraryPath = lib.makeLibraryPath (
35 []
36 ++ lib.optionals cudaSupport [ cudatoolkit.lib cudatoolkit.out nvidia_x11 ]
37 ++ lib.optionals openclSupport ([ clblas ] ++ lib.optional (!stdenv.isDarwin) ocl-icd)
38 );
39
40 preBuild = ''
41 make -j$NIX_BUILD_CORES
42 make install
43
44 export NIX_CFLAGS_COMPILE="-L $out/lib -I $out/include $NIX_CFLAGS_COMPILE"
45
46 cd ..
47 '';
48
49 postFixup = ''
50 rm $out/lib/libgpuarray-static.a
51 '' + stdenv.lib.optionalString (!stdenv.isDarwin) ''
52 function fixRunPath {
53 p=$(patchelf --print-rpath $1)
54 patchelf --set-rpath "$p:$libraryPath" $1
55 }
56
57 fixRunPath $out/lib/libgpuarray.so
58 '';
59
60 propagatedBuildInputs = [
61 numpy
62 six
63 Mako
64 ];
65
66 enableParallelBuilding = true;
67
68 nativeBuildInputs = [ cmake ];
69
70 buildInputs = [
71 cython
72 nose
73 ];
74
75 meta = with stdenv.lib; {
76 homepage = "https://github.com/Theano/libgpuarray";
77 description = "Library to manipulate tensors on GPU.";
78 license = licenses.free;
79 maintainers = with maintainers; [ artuuge ];
80 platforms = platforms.unix;
81 };
82
83}