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

cudnn*_cudatoolkit*: use public NVIDIA mirror #31551

Merged
merged 2 commits into from Jul 18, 2018

Conversation

lukeadams
Copy link
Contributor

@lukeadams lukeadams commented Nov 12, 2017

Motivation for this change

This PR dramatically simplifies the use of cudnn libraries on NixOS, which is used by most machine learning packages for gpu acceleration.

Previously, you would have to go through the NVIDIA developer portal and manually use nix-prefetch to add the tarballs to the store.

  • 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.

@grahamc
Copy link
Member

grahamc commented Nov 12, 2017

It looks like we are allowed to distribute this lib as long as we include this copyright notice: https://gitlab.com/nvidia/cuda/blob/centos7/LICENSE#L1

@lukeadams
Copy link
Contributor Author

lukeadams commented Nov 12, 2017

Would including the license in the meta be acceptable? Or print it while the package is being built?
edit:

[nix-shell:~/Downloads/cuda-centos7-f6f245a7021a77b875df0165de9ba2e1cd3ea342]$ ~/.gem/ruby/2.3.0/bin/licensee
License: Other
Matched files: ["LICENSE"]
LICENSE:
  Content hash: 7b9a4f39cac1caafd2220db5aa686606a1267ae5
  Attribution: Copyright (c) 2017, NVIDIA CORPORATION. All rights reserved.
  License: Other
  Closest licenses:
    * BSD-3-Clause similarity: 97.87%

So it's a BSD license. I'll add that when I fix the hash.
Would this work?
license = licenses.unfree ++ licenses.bsd3;

cudatoolkit = cudatoolkit7;
srcName = "cudnn-${cudatoolkit.majorVersion}-linux-x64-v${version}-prod.tgz";
srcName = "cudnn-${cudatoolkit.majorVersion}-linux-x64-v4.0-prod.tgz";
sha256 = "0zgr6qdbc29qw6sikhrh6diwwz7150rqc8a49f2qf37j2rvyyr2f";
Copy link
Member

Choose a reason for hiding this comment

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

output path ‘/nix/store/f1mc7z50dw66vdzjkp3ds03p7kn765sl-cudnn-7.0-linux-x64-v4.0-prod.tgz’ has sha256 hash ‘01a4v5j4v9n2xjqcc4m28c3m67qrvsx87npvy7zhx7w8smiif2fd’ when ‘0zgr6qdbc29qw6sikhrh6diwwz7150rqc8a49f2qf37j2rvyyr2f’ was expected

Copy link
Contributor Author

@lukeadams lukeadams Nov 15, 2017

Choose a reason for hiding this comment

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

Correct hash is 01a4v5j4v9n2xjqcc4m28c3m67qrvsx87npvy7zhx7w8smiif2fd
I'll update this PR friday

@lukeadams
Copy link
Contributor Author

lukeadams commented Nov 16, 2017

@grahamc I fixed the hash issue and re-tested (rebased on master), all successfully downloaded and built.

I added BSD3 to the license, but since the blobs being downloaded are unfree I left that in as well.

@lukeadams
Copy link
Contributor Author

Rebased as of today

@@ -49,7 +44,7 @@ stdenv.mkDerivation rec {
meta = with stdenv.lib; {
description = "NVIDIA CUDA Deep Neural Network library (cuDNN)";
homepage = "https://developer.nvidia.com/cudnn";
license = licenses.unfree;
license = [ licenses.unfree licenses.bsd3 ];
Copy link
Contributor

Choose a reason for hiding this comment

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

Does BSD3 apply to anything brought by this derivation, or is it just the license of Dockerfiles where you have found source URLs?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's just the license in the Dockerfiles repo, which I now realize is definitely not the cudnn license. It looks like this is the actual license on the NVIDIA site.
I can add the license to licenses.nix, something like

nvidia-cudnn = {
  fullName  = "NVIDIA SOFTWARE LICENSE AGREEMENT for cuDNN";
  url       = "http://docs.nvidia.com/deeplearning/sdk/pdf/cuDNN-SLA.pdf";
  free      = false;
};

cudnn and friends have been posted to AUR with license proprietary

Copy link
Contributor

Choose a reason for hiding this comment

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

IMHO just keeping the old unfree is fine. Then it looks ready to merge.

@lukeadams
Copy link
Contributor Author

@orivej I dropped the bsd3 commit

@lukeadams
Copy link
Contributor Author

@orivej Rebased 2018-02-10

@lukeadams
Copy link
Contributor Author

Rebased 2018-03-01

@lukeadams lukeadams force-pushed the cudnn_links branch 2 times, most recently from d008f93 to 01d433d Compare March 15, 2018 03:07
@lukeadams
Copy link
Contributor Author

Rebased 2018-03-14, fixed merge conflict. Ready for review/merge

@lukeadams
Copy link
Contributor Author

cc @orivej @grahamc
Rebased 2018-05-13

Since nox-review doesn't pick up the changes, the packages were tested with nix-build '<nixpkgs>' -I nixpkgs=/media/manual/nixpkgs-checkout/nixpkgs --no-out-link -A cudnn_cudatoolkit7 -A cudnn_cudatoolkit75 -A cudnn6_cudatoolkit8 -A cudnn_cudatoolkit8 -A cudnn_cudatoolkit9, which completes successfully.

@lukeadams
Copy link
Contributor Author

lukeadams commented Jun 27, 2018

@orivej @abbradar Are there any remaining issues? I just rebased and resolved the merge conflicts so it's still good to go afaik.

Copy link
Contributor

@jb55 jb55 left a comment

Choose a reason for hiding this comment

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

👍

@lukeadams
Copy link
Contributor Author

lukeadams commented Jul 17, 2018

cc @matthewbauer I just rebased and tested it again. Any chance we could get this merged?

@matthewbauer
Copy link
Member

matthewbauer commented Jul 17, 2018

Yeah looks good. Just to verify though - do we need to do anything special with the license in this case? If you thunk it is redistributable we should do unfreeRedistributable to the license.

@lukeadams
Copy link
Contributor Author

@matthewbauer orivej and I were talking about adding the CUDNN license on the nvidia site, but decided against it in favor of the license on the Dockerfile repo the source url is from.

Some debian maintainers were unsure of the redist status, so I'll probably leave it as unfree.
Would there be a way to have Hydra build+cache tensorflowWithCuda with it set as such?

@orivej-nixos orivej-nixos merged commit eba8679 into NixOS:master Jul 18, 2018
@orivej
Copy link
Contributor

orivej commented Jul 18, 2018

Thank you and sorry for the delay!

@lukeadams
Copy link
Contributor Author

:) no worries! Thanks to you both.

@lukeadams
Copy link
Contributor Author

@matthewbauer Hey sorry to ping you again, but is there a way to have Hydra build the cudnn/CUDA/tensorflowWithGpu packages but not cache the output (i.e. so it gets listed on hydra.nixos.org, but without allowing redistribution)?

@matthewbauer
Copy link
Member

matthewbauer commented Jul 19, 2018

No, I don't think there is a way to do that. Nix doesn't really separate out licenses of "buildPackages" vs "hostPackages". Everything either evaluates or not. This ties into some of the cross stuff & what I think @nh2 is working on. At one point in time you could put unfreeRedistributable in the license and Hydra would evaluate it - but that appears to have been removed. If you had your own Hydra instance you could still do something like that with this in your config:

let lib = import <nixpkgs/lib>;

in {
  allowUnfree = false;
  whitelistedLicenses = [ lib.licenses.unfreeRedistributable ];
}

Or make up some other license for it.

@CMCDragonkai
Copy link
Member

Awesome, I mentioned this a while ago. But if you want to do this on an older Nixpkgs hash this is what I did:

# 7.0.5
wget 'https://developer.download.nvidia.com/compute/redist/cudnn/v7.0.5/cudnn-9.0-linux-x64-v7.tgz'
wget 'https://developer.download.nvidia.com/compute/redist/cudnn/v7.0.5/cudnn-9.1-linux-x64-v7.tgz'
# 7.1.4
wget 'https://developer.download.nvidia.com/compute/redist/cudnn/v7.1.4/cudnn-9.2-linux-x64-v7.1.tgz'

# then use nix-store or nix-prefetch-url to load them to the /nix/store
nix-store --add-fixed sha256 ./cudnn-9.0-linux-x64-v7.tgz
nix-prefetch-url file:://$(pwd)/cudnn-9.0-linux-x64-v7.tgz

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

8 participants