2017-02-15 12:30:30 +01:00
|
|
|
{ stdenv
|
|
|
|
, fetchurl
|
|
|
|
, buildPythonPackage
|
2017-02-26 11:03:27 +01:00
|
|
|
, isPy35, isPy27
|
|
|
|
, cudaSupport ? false
|
2017-02-27 15:23:23 +01:00
|
|
|
, cudatoolkit ? null
|
|
|
|
, cudnn ? null
|
2017-02-26 11:03:27 +01:00
|
|
|
, linuxPackages ? null
|
2017-02-15 12:30:30 +01:00
|
|
|
, numpy
|
|
|
|
, six
|
2017-02-26 11:03:27 +01:00
|
|
|
, protobuf3_2
|
2017-02-15 12:30:30 +01:00
|
|
|
, swig
|
2017-05-05 16:57:59 +02:00
|
|
|
, werkzeug
|
2017-02-15 12:30:30 +01:00
|
|
|
, mock
|
|
|
|
, zlib
|
|
|
|
}:
|
|
|
|
|
2017-02-27 15:23:23 +01:00
|
|
|
assert cudaSupport -> cudatoolkit != null
|
|
|
|
&& cudnn != null
|
2017-02-26 11:03:27 +01:00
|
|
|
&& linuxPackages != null;
|
|
|
|
|
|
|
|
# unsupported combination
|
|
|
|
assert ! (stdenv.isDarwin && cudaSupport);
|
|
|
|
|
2017-02-15 12:30:30 +01:00
|
|
|
# tensorflow is built from a downloaded wheel, because the upstream
|
|
|
|
# project's build system is an arcane beast based on
|
|
|
|
# bazel. Untangling it and building the wheel from source is an open
|
|
|
|
# problem.
|
|
|
|
|
|
|
|
buildPythonPackage rec {
|
|
|
|
pname = "tensorflow";
|
2017-05-05 16:57:59 +02:00
|
|
|
version = "1.1.0";
|
2017-02-15 12:30:30 +01:00
|
|
|
name = "${pname}-${version}";
|
|
|
|
format = "wheel";
|
2017-02-26 11:03:27 +01:00
|
|
|
disabled = ! (isPy35 || isPy27);
|
2017-02-15 12:30:30 +01:00
|
|
|
|
2017-02-26 11:03:27 +01:00
|
|
|
src = let
|
|
|
|
tfurl = sys: proc: pykind:
|
|
|
|
let
|
|
|
|
tfpref = if proc == "gpu"
|
|
|
|
then "gpu/tensorflow_gpu"
|
|
|
|
else "cpu/tensorflow";
|
|
|
|
in
|
|
|
|
"https://storage.googleapis.com/tensorflow/${sys}/${tfpref}-${version}-${pykind}.whl";
|
|
|
|
dls =
|
|
|
|
{
|
|
|
|
darwin.cpu = {
|
|
|
|
py2 = {
|
|
|
|
url = tfurl "mac" "cpu" "py2-none-any" ;
|
2017-05-05 16:57:59 +02:00
|
|
|
sha256 = "1fgf26lw0liqxc9pywc8y2mj8l1mv48nhkav0pag9vavdacb9mqr";
|
2017-02-26 11:03:27 +01:00
|
|
|
};
|
|
|
|
py3 = {
|
|
|
|
url = tfurl "mac" "cpu" "py3-none-any" ;
|
2017-05-05 16:57:59 +02:00
|
|
|
sha256 = "0z5p1fra7bih0vqn618i2w3vyy8d1rkc72k7bmjq0rw8msl717ia";
|
2017-02-26 11:03:27 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
linux-x86_64.cpu = {
|
|
|
|
py2 = {
|
|
|
|
url = tfurl "linux" "cpu" "cp27-none-linux_x86_64";
|
2017-05-05 16:57:59 +02:00
|
|
|
sha256 = "0ld3hqx3idxk0zcrvn3p9yqnmx09zsj3mw66jlfw6fkv5hznx8j2";
|
2017-02-26 11:03:27 +01:00
|
|
|
};
|
|
|
|
py3 = {
|
|
|
|
url = tfurl "linux" "cpu" "cp35-cp35m-linux_x86_64";
|
2017-05-05 16:57:59 +02:00
|
|
|
sha256 = "0ahz9222rzqrk43lb9w4m351klkm6mlnnvw8xfqip28vbmymw90b";
|
2017-02-26 11:03:27 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
linux-x86_64.cuda = {
|
|
|
|
py2 = {
|
|
|
|
url = tfurl "linux" "gpu" "cp27-none-linux_x86_64";
|
2017-05-05 16:57:59 +02:00
|
|
|
sha256 = "1baa9jwr6f8f62dyx6isbw8yyrd0pi1dz1srjblfqsyk1x3pnfvh";
|
2017-02-26 11:03:27 +01:00
|
|
|
};
|
|
|
|
py3 = {
|
|
|
|
url = tfurl "linux" "gpu" "cp35-cp35m-linux_x86_64";
|
2017-05-05 16:57:59 +02:00
|
|
|
sha256 = "0606m2awy0ifhniy8lsyhd0xc388dgrwksn87989xlgy90wpxi92";
|
2017-02-26 11:03:27 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
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
|
|
|
|
);
|
2017-02-15 12:30:30 +01:00
|
|
|
|
2017-02-26 11:03:27 +01:00
|
|
|
propagatedBuildInputs = with stdenv.lib;
|
2017-05-05 16:57:59 +02:00
|
|
|
[ numpy six protobuf3_2 swig werkzeug mock ]
|
2017-05-29 19:24:34 +02:00
|
|
|
++ optionals cudaSupport [ cudatoolkit cudnn stdenv.cc ];
|
2017-02-15 12:30:30 +01:00
|
|
|
|
2017-02-26 11:03:27 +01:00
|
|
|
# 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
|
|
|
|
(if cudaSupport then
|
2017-05-29 19:24:34 +02:00
|
|
|
[ stdenv.cc.cc.lib zlib cudatoolkit cudnn
|
2017-02-26 11:03:27 +01:00
|
|
|
linuxPackages.nvidia_x11 ]
|
|
|
|
else
|
2017-05-29 19:24:34 +02:00
|
|
|
[ stdenv.cc.cc.lib zlib ]
|
2017-02-26 11:03:27 +01:00
|
|
|
);
|
|
|
|
in
|
|
|
|
''
|
|
|
|
find $out -name '*.so' -exec patchelf --set-rpath "${rpath}" {} \;
|
2017-02-15 12:30:30 +01:00
|
|
|
'';
|
|
|
|
|
|
|
|
doCheck = false;
|
|
|
|
|
|
|
|
meta = with stdenv.lib; {
|
2017-02-26 11:03:27 +01:00
|
|
|
description = "TensorFlow helps the tensors flow";
|
2017-02-15 12:30:30 +01:00
|
|
|
homepage = http://tensorflow.org;
|
|
|
|
license = licenses.asl20;
|
2017-05-05 16:57:59 +02:00
|
|
|
maintainers = with maintainers; [ jpbernardy ];
|
2017-02-26 11:03:27 +01:00
|
|
|
platforms = with platforms; if cudaSupport then linux else linux ++ darwin;
|
2017-02-15 12:30:30 +01:00
|
|
|
};
|
|
|
|
}
|