2017-09-17 16:03:00 +01:00
|
|
|
{ stdenv
|
2018-08-02 20:20:24 +01:00
|
|
|
, runCommandCC
|
2017-09-17 16:03:00 +01:00
|
|
|
, fetchPypi
|
|
|
|
, buildPythonPackage
|
|
|
|
, isPyPy
|
|
|
|
, pythonOlder
|
|
|
|
, isPy3k
|
|
|
|
, nose
|
|
|
|
, numpy
|
|
|
|
, scipy
|
|
|
|
, six
|
|
|
|
, libgpuarray
|
|
|
|
, cudaSupport ? false, cudatoolkit
|
|
|
|
, cudnnSupport ? false, cudnn
|
2018-05-13 13:23:12 +01:00
|
|
|
, nvidia_x11
|
2017-09-17 16:03:00 +01:00
|
|
|
}:
|
|
|
|
|
|
|
|
assert cudnnSupport -> cudaSupport;
|
|
|
|
|
2018-05-13 13:23:12 +01:00
|
|
|
assert cudaSupport -> nvidia_x11 != null
|
|
|
|
&& cudatoolkit != null
|
|
|
|
&& cudnn != null;
|
|
|
|
|
2017-09-17 16:03:00 +01:00
|
|
|
let
|
2018-08-02 20:20:24 +01:00
|
|
|
wrapped = command: buildTop: buildInputs:
|
|
|
|
runCommandCC "${command}-wrapped" { inherit buildInputs; } ''
|
|
|
|
type -P '${command}' || { echo '${command}: not found'; exit 1; }
|
|
|
|
cat > "$out" <<EOF
|
|
|
|
#!$(type -P bash)
|
|
|
|
$(declare -xp | sed -e '/^[^=]\+="\('"''${NIX_STORE//\//\\/}"'\|[^\/]\)/!d')
|
|
|
|
declare -x NIX_BUILD_TOP="${buildTop}"
|
|
|
|
$(type -P '${command}') "\$@"
|
|
|
|
EOF
|
|
|
|
chmod +x "$out"
|
|
|
|
'';
|
|
|
|
|
|
|
|
# Theano spews warnings and disabled flags if the compiler isn't named g++
|
2019-12-23 22:55:13 +00:00
|
|
|
cxx_compiler_name =
|
|
|
|
if stdenv.cc.isGNU then "g++" else
|
|
|
|
if stdenv.cc.isClang then "clang++" else
|
|
|
|
throw "Unknown C++ compiler";
|
|
|
|
cxx_compiler = wrapped cxx_compiler_name "\\$HOME/.theano"
|
2018-08-02 20:20:24 +01:00
|
|
|
( stdenv.lib.optional cudaSupport libgpuarray_
|
|
|
|
++ stdenv.lib.optional cudnnSupport cudnn );
|
2017-09-17 16:03:00 +01:00
|
|
|
|
2018-08-02 17:09:47 +01:00
|
|
|
libgpuarray_ = libgpuarray.override { inherit cudaSupport cudatoolkit; };
|
2017-09-17 16:03:00 +01:00
|
|
|
|
|
|
|
in buildPythonPackage rec {
|
|
|
|
pname = "Theano";
|
2019-01-17 15:13:08 +00:00
|
|
|
version = "1.0.4";
|
2017-09-17 16:03:00 +01:00
|
|
|
|
|
|
|
disabled = isPyPy || pythonOlder "2.6" || (isPy3k && pythonOlder "3.3");
|
|
|
|
|
|
|
|
src = fetchPypi {
|
|
|
|
inherit pname version;
|
2019-01-17 15:13:08 +00:00
|
|
|
sha256 = "35c9bbef56b61ffa299265a42a4e8f8cb5a07b2997dabaef0f8830b397086913";
|
2017-09-17 16:03:00 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
postPatch = ''
|
2018-08-02 17:20:21 +01:00
|
|
|
substituteInPlace theano/configdefaults.py \
|
2018-08-02 20:20:24 +01:00
|
|
|
--replace 'StrParam(param, is_valid=warn_cxx)' 'StrParam('\'''${cxx_compiler}'\''', is_valid=warn_cxx)' \
|
2018-08-02 17:20:21 +01:00
|
|
|
--replace 'rc == 0 and config.cxx != ""' 'config.cxx != ""'
|
|
|
|
'' + stdenv.lib.optionalString cudaSupport ''
|
|
|
|
substituteInPlace theano/configdefaults.py \
|
|
|
|
--replace 'StrParam(get_cuda_root)' 'StrParam('\'''${cudatoolkit}'\''')'
|
|
|
|
'' + stdenv.lib.optionalString cudnnSupport ''
|
|
|
|
substituteInPlace theano/configdefaults.py \
|
|
|
|
--replace 'StrParam(default_dnn_base_path)' 'StrParam('\'''${cudnn}'\''')'
|
2017-09-17 16:03:00 +01:00
|
|
|
'';
|
|
|
|
|
|
|
|
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 ];
|
|
|
|
};
|
|
|
|
}
|