pythonPackages.tensorflow: 0.10.0 -> 1.0.0

This commit is contained in:
Edward Tjörnhammar 2017-02-26 11:03:27 +01:00
parent a331662930
commit 7864782d71
No known key found for this signature in database
GPG Key ID: 7B82CE4A866B6845
3 changed files with 97 additions and 69 deletions

View File

@ -1,52 +0,0 @@
{ stdenv
, fetchurl
, buildPythonPackage
, swig
, numpy
, six
, protobuf3_0
, cudatoolkit75
, cudnn5_cudatoolkit75
, gcc49
, zlib
, linuxPackages
, mock
}:
buildPythonPackage rec {
pname = "tensorflow";
version = "0.11.0rc0";
name = "${pname}-${version}";
format = "wheel";
src = fetchurl {
url = "https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow-${version}-cp27-none-linux_x86_64.whl";
sha256 = "1r8zlz95sw7bnjzg5zdbpa9dj8wmp8cvvgyl9sv3amsscagnnfj5";
};
buildInputs = [ swig ];
propagatedBuildInputs = [ numpy six protobuf3_0 cudatoolkit75 cudnn5_cudatoolkit75 gcc49 mock ];
# Note that we need to run *after* the fixup phase because the
# libraries are loaded at runtime. If we run in preFixup then
# patchelf --shrink-rpath will remove the cuda libraries.
postFixup = let
rpath = stdenv.lib.makeLibraryPath [
gcc49.cc.lib
zlib cudatoolkit75
cudnn5_cudatoolkit75
linuxPackages.nvidia_x11
];
in ''
find $out -name '*.so' -exec patchelf --set-rpath "${rpath}" {} \;
'';
doCheck = false;
meta = with stdenv.lib; {
description = "TensorFlow helps the tensors flow (no gpu support)";
homepage = http://tensorflow.org;
license = licenses.asl20;
platforms = platforms.linux;
};
}

View File

@ -1,15 +1,29 @@
{ stdenv { stdenv
, fetchurl , fetchurl
, buildPythonPackage , buildPythonPackage
, isPy35, isPy27
, cudaSupport ? false
, cudatoolkit75 ? null
, cudnn5_cudatoolkit75 ? null
, gcc49 ? null
, linuxPackages ? null
, numpy , numpy
, six , six
, protobuf3_0_0b2 , protobuf3_2
, swig , swig
, mock , mock
, gcc , gcc
, zlib , zlib
}: }:
assert cudaSupport -> cudatoolkit75 != null
&& cudnn5_cudatoolkit75 != null
&& gcc49 != null
&& linuxPackages != null;
# unsupported combination
assert ! (stdenv.isDarwin && cudaSupport);
# tensorflow is built from a downloaded wheel, because the upstream # tensorflow is built from a downloaded wheel, because the upstream
# project's build system is an arcane beast based on # project's build system is an arcane beast based on
# bazel. Untangling it and building the wheel from source is an open # bazel. Untangling it and building the wheel from source is an open
@ -17,32 +31,96 @@
buildPythonPackage rec { buildPythonPackage rec {
pname = "tensorflow"; pname = "tensorflow";
version = "0.10.0"; version = "1.0.0";
name = "${pname}-${version}"; name = "${pname}-${version}";
format = "wheel"; format = "wheel";
disabled = ! (isPy35 || isPy27);
src = fetchurl { src = let
url = if stdenv.isDarwin then tfurl = sys: proc: pykind:
"https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-${version}-py2-none-any.whl" else let
"https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-${version}-cp27-none-linux_x86_64.whl"; tfpref = if proc == "gpu"
sha256 = if stdenv.isDarwin then then "gpu/tensorflow_gpu"
"1gjybh3j3rn34bzhsxsfdbqgsr4jh50qyx2wqywvcb24fkvy40j9" else else "cpu/tensorflow";
"0g05pa4z6kdy0giz7hjgjgwf4zzr5l8cf1zh247ymixlikn3fnpx"; in
}; "https://storage.googleapis.com/tensorflow/${sys}/${tfpref}-${version}-${pykind}.whl";
dls =
{
darwin.cpu = {
py2 = {
url = tfurl "mac" "cpu" "py2-none-any" ;
sha256 = "15ayil28p20wkgpwkr4mz0imjxnf049xx4117jspg1qkjg2bn1b2";
};
py3 = {
url = tfurl "mac" "cpu" "py3-none-any" ;
sha256 = "1ynyhbm7yrp421364s49a1r3p83zxy74iiy5c4hx2xm5c4gs29an";
};
};
linux-x86_64.cpu = {
py2 = {
url = tfurl "linux" "cpu" "cp27-none-linux_x86_64";
sha256 = "1hwhq1qhjrfkqfkxpsrq6mdmdibnqr3n7xvzkxp6gaqj73vn5ch2";
};
py3 = {
url = tfurl "linux" "cpu" "cp35-cp35m-linux_x86_64";
sha256 = "0jx2mmlw0nxah9l25r46i7diqiv31qcz7855n250lsxfwcppy7y3";
};
};
linux-x86_64.cuda = {
py2 = {
url = tfurl "linux" "gpu" "cp27-none-linux_x86_64";
sha256 = "0l8f71x3ama5a6idj05jrswlmp4yg37fxhz8lx2xmgk14aszbcy5";
};
py3 = {
url = tfurl "linux" "gpu" "cp35-cp35m-linux_x86_64";
sha256 = "12q7s0yk0h3r4glh0fhl1fcdx7jl8xikwwp04a1lcagasr51s36m";
};
};
};
in
fetchurl (
if stdenv.isDarwin then
if isPy35 then
dls.darwin.cpu.py3
else
dls.darwin.cpu.py2
else if isPy35 then
if cudaSupport then
dls.linux-x86_64.cuda.py3
else dls.linux-x86_64.cpu.py3
else
if cudaSupport then
dls.linux-x86_64.cuda.py2
else
dls.linux-x86_64.cpu.py2
);
propagatedBuildInputs = [ numpy six protobuf3_0_0b2 swig mock]; propagatedBuildInputs = with stdenv.lib;
[ numpy six protobuf3_2 swig mock ]
++ optionals cudaSupport [ cudatoolkit75 cudnn5_cudatoolkit75 gcc49 ];
preFixup = '' # Note that we need to run *after* the fixup phase because the
RPATH="${stdenv.lib.makeLibraryPath [ gcc.cc.lib zlib ]}" # libraries are loaded at runtime. If we run in preFixup then
find $out -name '*.so' -exec patchelf --set-rpath "$RPATH" {} \; # patchelf --shrink-rpath will remove the cuda libraries.
postFixup = let
rpath = stdenv.lib.makeLibraryPath
(if cudaSupport then
[ gcc49.cc.lib zlib cudatoolkit75 cudnn5_cudatoolkit75
linuxPackages.nvidia_x11 ]
else
[ gcc.cc.lib zlib ]
);
in
''
find $out -name '*.so' -exec patchelf --set-rpath "${rpath}" {} \;
''; '';
doCheck = false; doCheck = false;
meta = with stdenv.lib; { meta = with stdenv.lib; {
description = "TensorFlow helps the tensors flow (no gpu support)"; description = "TensorFlow helps the tensors flow";
homepage = http://tensorflow.org; homepage = http://tensorflow.org;
license = licenses.asl20; license = licenses.asl20;
platforms = with platforms; linux ++ darwin; platforms = with platforms; if cudaSupport then linux else linux ++ darwin;
}; };
} }

View File

@ -31254,7 +31254,9 @@ EOF
tensorflowWithoutCuda = callPackage ../development/python-modules/tensorflow { }; tensorflowWithoutCuda = callPackage ../development/python-modules/tensorflow { };
tensorflowWithCuda = callPackage ../development/python-modules/tensorflow/cuda.nix { }; tensorflowWithCuda = callPackage ../development/python-modules/tensorflow {
cudaSupport = true;
};
tflearn = buildPythonPackage rec { tflearn = buildPythonPackage rec {
name = "tflearn-0.2.1"; name = "tflearn-0.2.1";