Skip to content

python.pkgs.tensorflow: wheel version #41259

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 7, 2018
Merged

python.pkgs.tensorflow: wheel version #41259

merged 3 commits into from
Jun 7, 2018

Conversation

jyp
Copy link
Contributor

@jyp jyp commented May 30, 2018

Motivation for this change

Tensorflow is broken in master.

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option build-use-sandbox in nix.conf on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nox --run "nox-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Fits CONTRIBUTING.md.

@jyp jyp requested a review from FRidh as a code owner May 30, 2018 14:41
@GrahamcOfBorg GrahamcOfBorg added 6.topic: python Python is a high-level, general-purpose programming language. 8.has: package (new) This PR adds a new package 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. 10.rebuild-linux: 11-100 This PR causes between 11 and 100 packages to rebuild on Linux. labels May 30, 2018
@@ -192,6 +192,13 @@ in {
gcc = gcc5;
};

cudatoolkit90 = common {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cudatoolkit90 while we have cudatoolkit9 is very confusing.

Would you mind rewriting these all to cudatoolkit_X_X or cudatoolkit_X in a separate commit, which will form the base for this change?

};
src = let dls = import ./tf1.7.1-hashes.nix;
in
fetchurl (
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's ugly. Maybe the following?

let
  version = python.majorVersion if stdenv.isDarwin else "${python.majorVersion}{python.minorVersion}";
  platform = "mac" if stdenv.isDarwin else "linux";
  unit = "gpu" if cudaSupport else "cpu";
  key = "${platform}_py_${version}_${unit}";
in dls.${key}

We don't support Python 3.4 and 3.5 so I think this should work.

# patchelf --shrink-rpath will remove the cuda libraries.
postFixup = let
rpath = stdenv.lib.makeLibraryPath
(if cudaSupport then
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use lib.optionals for the extra items.

''
rrPath="$out/${python.sitePackages}/tensorflow/:${rpath}"
internalLibPath="$out/${python.sitePackages}/tensorflow/python/_pywrap_tensorflow_internal.so"
find $out -name '*.so' -exec patchelf --set-rpath "$rrPath" {} \;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.so is linux only, so use .${stdenv.hostPlatform.extensions.sharedLibrary}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

patchelf is also linux only so the whole find commands needs to be made conditional.

meta = with stdenv.lib; {
description = "Computation using data flow graphs for scalable machine learning";
homepage = http://tensorflow.org;
license = licenses.asl20;
maintainers = with maintainers; [ jyp abbradar ];
platforms = platforms.darwin;
platforms = with platforms; if cudaSupport then linux else linux ++ darwin;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lib.optionals

sha256 = "0s5dy956jvwazqflc90v15i912zvhwsbzlf0cl8k7isq52j6g3kp";
};
}
# This file, prefetcher.sh, was generated using the following script:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just check in the script in a separate file

@FRidh FRidh changed the title Tf 1.7.1 bin python.pkgs.tensorflow: wheel version May 30, 2018
@jyp jyp force-pushed the tf-1.7.1-bin branch 3 times, most recently from 55eae50 to 442d3e6 Compare May 31, 2018 07:47
@jyp
Copy link
Contributor Author

jyp commented May 31, 2018

@FRidh Thanks for the review!

I think I've applied all your comments in the current version.

@jyp
Copy link
Contributor Author

jyp commented May 31, 2018 via email

jyp added 3 commits May 31, 2018 22:21
This version is a dependency of tensorflow binaries
Re-instates binary build for all versions.
@GrahamcOfBorg GrahamcOfBorg added the 8.has: clean-up This PR removes packages or removes other cruft label May 31, 2018
@jyp
Copy link
Contributor Author

jyp commented Jun 7, 2018

@FRidh I believe that the PR satisfies your suggestions. What do you think?

@FRidh FRidh merged commit 4dc7cc8 into NixOS:master Jun 7, 2018
@dotlambda
Copy link
Member

I'm getting

$ nix-build -A python2.pkgs.tensorflow
these derivations will be built:
  /nix/store/clmfhq0nl767d1h61drjgm1qxzbgsq1b-python2.7-tensorflow-1.7.1.drv
building '/nix/store/clmfhq0nl767d1h61drjgm1qxzbgsq1b-python2.7-tensorflow-1.7.1.drv'...
unpacking sources
patching sources
configuring
building
installing
/build/dist /build
Processing ./tensorflow-1.7.1-cp27-none-linux_x86_64.whl
Requirement already satisfied: protobuf>=3.4.0 in /nix/store/rlrjqlpsqvlrhjpk5v9zzhsvdpmmi0dp-python2.7-protobuf-3.5.1.1/lib/python2.7/site-packages (from tensorflow==1.7.1) (3.5.1)
Collecting astor>=0.6.0 (from tensorflow==1.7.1)
  Could not find a version that satisfies the requirement astor>=0.6.0 (from tensorflow==1.7.1) (from versions: )
No matching distribution found for astor>=0.6.0 (from tensorflow==1.7.1)
builder for '/nix/store/clmfhq0nl767d1h61drjgm1qxzbgsq1b-python2.7-tensorflow-1.7.1.drv' failed with exit code 1

@jyp
Copy link
Contributor Author

jyp commented Jun 7, 2018

@dotlambda If you're targetting py 3.6 it'll work, but not with eager graph execution. Would you care submitting a bug report?
I'd fix the issue right away, but I see also that the package gast is needed too, and it is currently not in nixpkgs.

@mboes mboes mentioned this pull request Jun 23, 2018
8 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
6.topic: python Python is a high-level, general-purpose programming language. 8.has: clean-up This PR removes packages or removes other cruft 8.has: package (new) This PR adds a new package 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. 10.rebuild-linux: 11-100 This PR causes between 11 and 100 packages to rebuild on Linux.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants