Skip to content
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

python3Packages.pytorch: create separate lib output #92617

Merged
merged 1 commit into from Jul 12, 2020

Conversation

danieldk
Copy link
Contributor

@danieldk danieldk commented Jul 7, 2020

Motivation for this change

At some point pytorch.dev was added to expose the libtorch headers and
libraries to non-Python users of libtorch. However, this output
currently has two disadvantages:

  1. An application that compiles against the dev output will also have
    the libtorch header files in its closure. This is not so nice when
    e.g. building Docker images of applications that use libtorch.
  2. The dev output has a large transitive closure with many dependencies
    that are not necessary when compiling against libtorch.

This change adds the lib output so that applications that only link
against libtorch libraries have a small closure.

Tested CUDA build ✔️

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS linux)
  • 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 nixpkgs-review --run "nixpkgs-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Ensured that relevant documentation is up to date
  • Fits CONTRIBUTING.md.

@jonringer
Copy link
Contributor

do you mind posting the closure savings? as that's the primary goal of the pr?

At some point pytorch.dev was added to expose the libtorch headers and
libraries to non-Python users of libtorch. However, this output
currently has two disadvantages:

1. An application that compiles against the dev output will also have
   the libtorch header files in its closure. This is not so nice when
   e.g. building Docker images of applications that use libtorch.
2. The dev output has a large transitive closure with many dependencies
   that are not necessary when compiling against libtorch.

This change adds the `lib` output so that applications that only link
against libtorch libraries have a small closure.

Before this change, the libtorch dependency adds 746MiB:

% nix path-info -S `realpath result-dev`
/nix/store/10rmy81bjk628sfpbj2szxlws6brq1xn-python3.8-pytorch-1.5.1-dev   782203848

With this change it is reduced to 196MiB:

% nix path-info -S `realpath result-lib`
/nix/store/bck65lf0z7gdhcf89w1zs5nz333lhgwa-python3.8-pytorch-1.5.1-lib   205865056
@danieldk
Copy link
Contributor Author

danieldk commented Jul 8, 2020

Good point. I have amended the commit message with the following:

Before this change, the libtorch dependency adds 746MiB:

% nix path-info -S `realpath result-dev`
/nix/store/10rmy81bjk628sfpbj2szxlws6brq1xn-python3.8-pytorch-1.5.1-dev   782203848

With this change it is reduced to 196MiB:

% nix path-info -S `realpath result-lib`
/nix/store/bck65lf0z7gdhcf89w1zs5nz333lhgwa-python3.8-pytorch-1.5.1-lib   205865056

@danieldk
Copy link
Contributor Author

Any objections to merging this?

@FRidh FRidh merged commit 2611e96 into NixOS:master Jul 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants