python.pkgs.Theano: merge CUDA and non-CUDA versions
This commit is contained in:
parent
efd2444de5
commit
771e403786
75
pkgs/development/python-modules/Theano/default.nix
Normal file
75
pkgs/development/python-modules/Theano/default.nix
Normal file
|
@ -0,0 +1,75 @@
|
|||
{ stdenv
|
||||
, lib
|
||||
, fetchPypi
|
||||
, gcc
|
||||
, writeScriptBin
|
||||
, buildPythonPackage
|
||||
, isPyPy
|
||||
, pythonOlder
|
||||
, isPy3k
|
||||
, nose
|
||||
, numpy
|
||||
, pydot_ng
|
||||
, scipy
|
||||
, six
|
||||
, libgpuarray
|
||||
, cudaSupport ? false, cudatoolkit
|
||||
, cudnnSupport ? false, cudnn
|
||||
}:
|
||||
|
||||
assert cudnnSupport -> cudaSupport;
|
||||
|
||||
let
|
||||
extraFlags =
|
||||
lib.optionals cudaSupport [ "-I ${cudatoolkit}/include" "-L ${cudatoolkit}/lib" ]
|
||||
++ lib.optionals cudnnSupport [ "-I ${cudnn}/include" "-L ${cudnn}/lib" ];
|
||||
|
||||
gcc_ = writeScriptBin "g++" ''
|
||||
#!${stdenv.shell}
|
||||
export NIX_CFLAGS_COMPILE="$NIX_CFLAGS_COMPILE ${toString extraFlags}"
|
||||
exec ${gcc}/bin/g++ "$@"
|
||||
'';
|
||||
|
||||
libgpuarray_ = libgpuarray.override { inherit cudaSupport; };
|
||||
|
||||
in buildPythonPackage rec {
|
||||
name = "${pname}-${version}";
|
||||
pname = "Theano";
|
||||
version = "0.9.0";
|
||||
|
||||
disabled = isPyPy || pythonOlder "2.6" || (isPy3k && pythonOlder "3.3");
|
||||
|
||||
src = fetchPypi {
|
||||
inherit pname version;
|
||||
sha256 = "05xwg00da8smkvkh6ywbywqzj8dw7x840jr74wqhdy9icmqncpbl";
|
||||
};
|
||||
|
||||
postPatch = ''
|
||||
sed -i 's,g++,${gcc_}/bin/g++,g' theano/configdefaults.py
|
||||
'' + lib.optionalString cudnnSupport ''
|
||||
sed -i \
|
||||
-e "s,ctypes.util.find_library('cudnn'),'${cudnn}/lib/libcudnn.so',g" \
|
||||
-e "s/= _dnn_check_compile()/= (True, None)/g" \
|
||||
theano/gpuarray/dnn.py
|
||||
'';
|
||||
|
||||
preCheck = ''
|
||||
mkdir -p check-phase
|
||||
export HOME=$(pwd)/check-phase
|
||||
'';
|
||||
doCheck = false;
|
||||
# takes far too long, also throws "TypeError: sort() missing 1 required positional argument: 'a'"
|
||||
# when run from the installer, and testing with Python 3.5 hits github.com/Theano/Theano/issues/4276,
|
||||
# the fix for which hasn't been merged yet.
|
||||
|
||||
# keep Nose around since running the tests by hand is possible from Python or bash
|
||||
checkInputs = [ nose ];
|
||||
propagatedBuildInputs = [ numpy numpy.blas scipy six libgpuarray_ ];
|
||||
|
||||
meta = with stdenv.lib; {
|
||||
homepage = http://deeplearning.net/software/theano/;
|
||||
description = "A Python library for large-scale array computation";
|
||||
license = licenses.bsd3;
|
||||
maintainers = with maintainers; [ maintainers.bcdarwin ];
|
||||
};
|
||||
}
|
|
@ -1,65 +0,0 @@
|
|||
{ buildPythonPackage
|
||||
, fetchFromGitHub
|
||||
, pythonOlder
|
||||
, future
|
||||
, numpy
|
||||
, six
|
||||
, scipy
|
||||
, nose
|
||||
, nose-parameterized
|
||||
, pydot_ng
|
||||
, sphinx
|
||||
, pygments
|
||||
, libgpuarray
|
||||
, python
|
||||
, pycuda
|
||||
, cudatoolkit
|
||||
, cudnn
|
||||
, stdenv
|
||||
}:
|
||||
|
||||
buildPythonPackage rec {
|
||||
name = "Theano-cuda-${version}";
|
||||
version = "0.8.2";
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "Theano";
|
||||
repo = "Theano";
|
||||
rev = "46fbfeb628220b5e42bf8277a5955c52d153e874";
|
||||
sha256 = "1sl91gli3jaw5gpjqqab4fiq4x6282spqciaid1s65pjsf3k55sc";
|
||||
};
|
||||
|
||||
doCheck = false;
|
||||
|
||||
patchPhase = ''
|
||||
pushd theano/sandbox/gpuarray
|
||||
sed -i -re '2s/^/from builtins import bytes\n/g' subtensor.py
|
||||
sed -i -re "s/(b'2')/int(bytes(\1))/g" subtensor.py
|
||||
sed -i -re "s/(ctx.bin_id\[\-2\])/int(\1)/g" subtensor.py
|
||||
|
||||
sed -i -re '2s/^/from builtins import bytes\n/g' dnn.py
|
||||
sed -i -re "s/(b'30')/int(bytes(\1))/g" dnn.py
|
||||
sed -i -re "s/(ctx.bin_id\[\-2:\])/int(\1)/g" dnn.py
|
||||
popd
|
||||
'';
|
||||
|
||||
dontStrip = true;
|
||||
|
||||
propagatedBuildInputs = [
|
||||
numpy.blas
|
||||
numpy
|
||||
six
|
||||
scipy
|
||||
nose
|
||||
nose-parameterized
|
||||
pydot_ng
|
||||
sphinx
|
||||
pygments
|
||||
pycuda
|
||||
cudatoolkit
|
||||
libgpuarray
|
||||
cudnn
|
||||
] ++ (stdenv.lib.optional (pythonOlder "3.0") future);
|
||||
|
||||
passthru.cudaSupport = true;
|
||||
}
|
|
@ -1,44 +0,0 @@
|
|||
{ stdenv
|
||||
, fetchurl
|
||||
, buildPythonPackage
|
||||
, isPyPy
|
||||
, pythonOlder
|
||||
, isPy3k
|
||||
, nose
|
||||
, numpy
|
||||
, pydot_ng
|
||||
, scipy
|
||||
, six
|
||||
}:
|
||||
|
||||
buildPythonPackage rec {
|
||||
name = "Theano-0.9.0";
|
||||
|
||||
disabled = isPyPy || pythonOlder "2.6" || (isPy3k && pythonOlder "3.3");
|
||||
|
||||
src = fetchurl {
|
||||
url = "mirror://pypi/T/Theano/${name}.tar.gz";
|
||||
sha256 = "05xwg00da8smkvkh6ywbywqzj8dw7x840jr74wqhdy9icmqncpbl";
|
||||
};
|
||||
|
||||
#preCheck = ''
|
||||
# mkdir -p check-phase
|
||||
# export HOME=$(pwd)/check-phase
|
||||
#'';
|
||||
doCheck = false;
|
||||
# takes far too long, also throws "TypeError: sort() missing 1 required positional argument: 'a'"
|
||||
# when run from the installer, and testing with Python 3.5 hits github.com/Theano/Theano/issues/4276,
|
||||
# the fix for which hasn't been merged yet.
|
||||
|
||||
# keep Nose around since running the tests by hand is possible from Python or bash
|
||||
propagatedBuildInputs = [ nose numpy numpy.blas pydot_ng scipy six ];
|
||||
|
||||
meta = {
|
||||
homepage = http://deeplearning.net/software/theano/;
|
||||
description = "A Python library for large-scale array computation";
|
||||
license = stdenv.lib.licenses.bsd3;
|
||||
maintainers = [ stdenv.lib.maintainers.bcdarwin ];
|
||||
};
|
||||
|
||||
passthru.cudaSupport = false;
|
||||
}
|
|
@ -19833,24 +19833,20 @@ in {
|
|||
|
||||
stevedore = callPackage ../development/python-modules/stevedore {};
|
||||
|
||||
Theano = self.TheanoWithoutCuda;
|
||||
Theano = callPackage ../development/python-modules/Theano rec {
|
||||
cudaSupport = pkgs.config.cudaSupport or false;
|
||||
cudnnSupport = cudaSupport;
|
||||
};
|
||||
|
||||
TheanoWithoutCuda = callPackage ../development/python-modules/Theano/theano-without-cuda { };
|
||||
TheanoWithoutCuda = self.Theano.override {
|
||||
cudaSupport = true;
|
||||
cudnnSupport = true;
|
||||
};
|
||||
|
||||
TheanoWithCuda = callPackage ../development/python-modules/Theano/theano-with-cuda (
|
||||
let
|
||||
boost = pkgs.boost159.override {
|
||||
inherit (self) python numpy scipy;
|
||||
};
|
||||
in rec {
|
||||
cudatoolkit = pkgs.cudatoolkit75;
|
||||
cudnn = pkgs.cudnn5_cudatoolkit75;
|
||||
inherit (self) numpy scipy;
|
||||
pycuda = self.pycuda.override { inherit boost; };
|
||||
libgpuarray = self.libgpuarray-cuda.override {
|
||||
clblas = pkgs.clblas-cuda.override { inherit boost; };
|
||||
};
|
||||
});
|
||||
TheanoWithCuda = self.Theano.override {
|
||||
cudaSupport = false;
|
||||
cudnnSupport = false;
|
||||
};
|
||||
|
||||
tidylib = buildPythonPackage rec {
|
||||
version = "0.2.4";
|
||||
|
|
Loading…
Reference in a new issue