at 18.03-beta 2.1 kB view raw
1{ stdenv 2, lib 3, fetchPypi 4, gcc 5, writeScriptBin 6, buildPythonPackage 7, isPyPy 8, pythonOlder 9, isPy3k 10, nose 11, numpy 12, pydot_ng 13, scipy 14, six 15, libgpuarray 16, cudaSupport ? false, cudatoolkit 17, cudnnSupport ? false, cudnn 18}: 19 20assert cudnnSupport -> cudaSupport; 21 22let 23 extraFlags = 24 lib.optionals cudaSupport [ "-I ${cudatoolkit}/include" "-L ${cudatoolkit}/lib" ] 25 ++ lib.optionals cudnnSupport [ "-I ${cudnn}/include" "-L ${cudnn}/lib" ]; 26 27 gcc_ = writeScriptBin "g++" '' 28 #!${stdenv.shell} 29 export NIX_CFLAGS_COMPILE="$NIX_CFLAGS_COMPILE ${toString extraFlags}" 30 exec ${gcc}/bin/g++ "$@" 31 ''; 32 33 libgpuarray_ = libgpuarray.override { inherit cudaSupport; }; 34 35in buildPythonPackage rec { 36 name = "${pname}-${version}"; 37 pname = "Theano"; 38 version = "1.0.1"; 39 40 disabled = isPyPy || pythonOlder "2.6" || (isPy3k && pythonOlder "3.3"); 41 42 src = fetchPypi { 43 inherit pname version; 44 sha256 = "88d8aba1fe2b6b75eacf455d01bc7e31e838c5a0fb8c13dde2d9472495ff4662"; 45 }; 46 47 postPatch = '' 48 sed -i 's,g++,${gcc_}/bin/g++,g' theano/configdefaults.py 49 '' + lib.optionalString cudnnSupport '' 50 sed -i \ 51 -e "s,ctypes.util.find_library('cudnn'),'${cudnn}/lib/libcudnn.so',g" \ 52 -e "s/= _dnn_check_compile()/= (True, None)/g" \ 53 theano/gpuarray/dnn.py 54 ''; 55 56 preCheck = '' 57 mkdir -p check-phase 58 export HOME=$(pwd)/check-phase 59 ''; 60 doCheck = false; 61 # takes far too long, also throws "TypeError: sort() missing 1 required positional argument: 'a'" 62 # when run from the installer, and testing with Python 3.5 hits github.com/Theano/Theano/issues/4276, 63 # the fix for which hasn't been merged yet. 64 65 # keep Nose around since running the tests by hand is possible from Python or bash 66 checkInputs = [ nose ]; 67 propagatedBuildInputs = [ numpy numpy.blas scipy six libgpuarray_ ]; 68 69 meta = with stdenv.lib; { 70 homepage = http://deeplearning.net/software/theano/; 71 description = "A Python library for large-scale array computation"; 72 license = licenses.bsd3; 73 maintainers = with maintainers; [ maintainers.bcdarwin ]; 74 }; 75}