From 05efe64c1bcee8af8d0ae20ca0e3aef164fc8c88 Mon Sep 17 00:00:00 2001 From: John Ericson Date: Wed, 3 Mar 2021 23:53:43 +0000 Subject: [PATCH 1/4] cudatensor: Init at 1.2.2 --- .../science/math/cutensor/default.nix | 37 ++++++++++ .../science/math/cutensor/generic.nix | 69 +++++++++++++++++++ pkgs/top-level/all-packages.nix | 12 ++++ 3 files changed, 118 insertions(+) create mode 100644 pkgs/development/libraries/science/math/cutensor/default.nix create mode 100644 pkgs/development/libraries/science/math/cutensor/generic.nix diff --git a/pkgs/development/libraries/science/math/cutensor/default.nix b/pkgs/development/libraries/science/math/cutensor/default.nix new file mode 100644 index 00000000000..1b5895b02bb --- /dev/null +++ b/pkgs/development/libraries/science/math/cutensor/default.nix @@ -0,0 +1,37 @@ +{ callPackage +, cudatoolkit_10_1, cudatoolkit_10_2 +, cudatoolkit_11_0, cudatoolkit_11_1, cudatoolkit_11_2 +}: + +rec { + cutensor_cudatoolkit_10_1 = callPackage ./generic.nix rec { + version = "1.2.2.5"; + libPath = "lib/10.1"; + cudatoolkit = cudatoolkit_10_1; + # 1.2.2 is compatible with CUDA 11.0, 11.1, and 11.2: + # ephemeral doc at https://developer.nvidia.com/cutensor/downloads + sha256 = "1dl9bd71frhac9cb8lvnh71zfsnqxbxbfhndvva2zf6nh0my4klm"; + }; + + cutensor_cudatoolkit_10_2 = cutensor_cudatoolkit_10_1.override { + libPath = "lib/10.2"; + cudatoolkit = cudatoolkit_10_2; + }; + + cutensor_cudatoolkit_10 = cutensor_cudatoolkit_10_2; + + cutensor_cudatoolkit_11_0 = cutensor_cudatoolkit_10_2.override { + libPath = "lib/11"; + cudatoolkit = cudatoolkit_11_0; + }; + + cutensor_cudatoolkit_11_1 = cutensor_cudatoolkit_11_0.override { + cudatoolkit = cudatoolkit_11_1; + }; + + cutensor_cudatoolkit_11_2 = cutensor_cudatoolkit_11_0.override { + cudatoolkit = cudatoolkit_11_2; + }; + + cutensor_cudatoolkit_11 = cutensor_cudatoolkit_11_2; +} diff --git a/pkgs/development/libraries/science/math/cutensor/generic.nix b/pkgs/development/libraries/science/math/cutensor/generic.nix new file mode 100644 index 00000000000..31b7dbdb8de --- /dev/null +++ b/pkgs/development/libraries/science/math/cutensor/generic.nix @@ -0,0 +1,69 @@ +{ stdenv +, lib +, libPath +, cudatoolkit +, fetchurl +, autoPatchelfHook +, addOpenGLRunpath + +, version +, sha256 +}: + +let + mostOfVersion = builtins.concatStringsSep "." + (lib.take 3 (lib.versions.splitVersion version)); +in + +stdenv.mkDerivation { + pname = "cudatoolkit-${cudatoolkit.majorVersion}-cutensor"; + inherit version; + + src = fetchurl { + url = "https://developer.download.nvidia.com/compute/cutensor/${mostOfVersion}/local_installers/libcutensor-${stdenv.hostPlatform.parsed.kernel.name}-${stdenv.hostPlatform.parsed.cpu.name}-${version}.tar.gz"; + inherit sha256; + }; + + outputs = [ "out" "dev" ]; + + nativeBuildInputs = [ + autoPatchelfHook + addOpenGLRunpath + ]; + + buildInputs = [ + stdenv.cc.cc.lib + ]; + + propagatedBuildInputs = [ + cudatoolkit + ]; + + # Set RUNPATH so that libcuda in /run/opengl-driver(-32)/lib can be found. + # See the explanation in addOpenGLRunpath. + installPhase = '' + mkdir -p "$out" "$dev" + mv include "$dev" + mv ${libPath} "$out/lib" + + function finalRPathFixups { + for lib in $out/lib/lib*.so; do + addOpenGLRunpath $lib + done + } + postFixupHooks+=(finalRPathFixups) + ''; + + passthru = { + inherit cudatoolkit; + majorVersion = lib.versions.major version; + }; + + meta = with lib; { + description = "cuTENSOR: A High-Performance CUDA Library For Tensor Primitives"; + homepage = "https://developer.nvidia.com/cutensor"; + license = licenses.unfree; + platforms = [ "x86_64-linux" ]; + maintainers = with maintainers; [ obsidian-systems-maintainence ]; + }; +} diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 8b40b3f8877..25e6481698c 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -3540,6 +3540,18 @@ in cudnn = cudnn_cudatoolkit_10; + cutensorPackages = callPackages ../development/libraries/science/math/cutensor { }; + inherit (cutensorPackages) + cutensor_cudatoolkit_10 + cutensor_cudatoolkit_10_1 + cutensor_cudatoolkit_10_2 + cutensor_cudatoolkit_11 + cutensor_cudatoolkit_11_0 + cutensor_cudatoolkit_11_1 + cutensor_cudatoolkit_11_2; + + cutensor = cutensor_cudatoolkit_10; + curlFull = curl.override { idnSupport = true; ldapSupport = true; From a680b02816260761e6ed609bdfc6fecb250e5784 Mon Sep 17 00:00:00 2001 From: John Ericson Date: Fri, 12 Mar 2021 15:06:09 -0500 Subject: [PATCH 2/4] tests.cude.cuda-library-samples.cutensor: init at same version as others --- .../cuda/cuda-library-samples/default.nix | 7 +++++++ .../cuda/cuda-library-samples/generic.nix | 19 +++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/pkgs/test/cuda/cuda-library-samples/default.nix b/pkgs/test/cuda/cuda-library-samples/default.nix index 501828c9a1f..91095fbd3ac 100644 --- a/pkgs/test/cuda/cuda-library-samples/default.nix +++ b/pkgs/test/cuda/cuda-library-samples/default.nix @@ -1,16 +1,20 @@ { callPackage , cudatoolkit_10_1, cudatoolkit_10_2 , cudatoolkit_11_0, cudatoolkit_11_1, cudatoolkit_11_2 +, cutensor_cudatoolkit_10_1, cutensor_cudatoolkit_10_2 +, cutensor_cudatoolkit_11_0, cutensor_cudatoolkit_11_1, cutensor_cudatoolkit_11_2 }: rec { cuda-library-samples_cudatoolkit_10_1 = callPackage ./generic.nix { cudatoolkit = cudatoolkit_10_1; + cutensor_cudatoolkit = cutensor_cudatoolkit_10_1; }; cuda-library-samples_cudatoolkit_10_2 = callPackage ./generic.nix { cudatoolkit = cudatoolkit_10_2; + cutensor_cudatoolkit = cutensor_cudatoolkit_10_2; }; cuda-library-samples_cudatoolkit_10 = @@ -20,14 +24,17 @@ rec { cuda-library-samples_cudatoolkit_11_0 = callPackage ./generic.nix { cudatoolkit = cudatoolkit_11_0; + cutensor_cudatoolkit = cutensor_cudatoolkit_11_0; }; cuda-library-samples_cudatoolkit_11_1 = callPackage ./generic.nix { cudatoolkit = cudatoolkit_11_1; + cutensor_cudatoolkit = cutensor_cudatoolkit_11_1; }; cuda-library-samples_cudatoolkit_11_2 = callPackage ./generic.nix { cudatoolkit = cudatoolkit_11_2; + cutensor_cudatoolkit = cutensor_cudatoolkit_11_2; }; cuda-library-samples_cudatoolkit_11 = diff --git a/pkgs/test/cuda/cuda-library-samples/generic.nix b/pkgs/test/cuda/cuda-library-samples/generic.nix index 75d4541d986..999e2abd041 100644 --- a/pkgs/test/cuda/cuda-library-samples/generic.nix +++ b/pkgs/test/cuda/cuda-library-samples/generic.nix @@ -1,6 +1,7 @@ { lib, stdenv, fetchFromGitHub , cmake, addOpenGLRunpath , cudatoolkit +, cutensor_cudatoolkit }: let @@ -48,4 +49,22 @@ in sourceRoot = "cuSOLVER/gesv"; }); + + cutensor = stdenv.mkDerivation (commonAttrs // { + pname = "cuda-library-samples-cutensor"; + + src = "${src}/cuTENSOR"; + + cmakeFlags = [ + "-DCUTENSOR_EXAMPLE_BINARY_INSTALL_DIR=${builtins.placeholder "out"}/bin" + ]; + + # CUTENSOR_ROOT is double escaped + postPatch = '' + substituteInPlace CMakeLists.txt \ + --replace "\''${CUTENSOR_ROOT}/include" "${cutensor_cudatoolkit.dev}/include" + ''; + + CUTENSOR_ROOT = cutensor_cudatoolkit; + }); } From 13b5995f06ec0ff5efeefd7ca6667d2acf5fb254 Mon Sep 17 00:00:00 2001 From: John Ericson Date: Mon, 15 Mar 2021 23:09:15 +0000 Subject: [PATCH 3/4] python37Packages.cupy: Add cutensor optional dep --- pkgs/development/python-modules/cupy/default.nix | 3 ++- pkgs/top-level/python-packages.nix | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/pkgs/development/python-modules/cupy/default.nix b/pkgs/development/python-modules/cupy/default.nix index 5c4978a388f..d4b42ac83e8 100644 --- a/pkgs/development/python-modules/cupy/default.nix +++ b/pkgs/development/python-modules/cupy/default.nix @@ -1,7 +1,7 @@ { lib, buildPythonPackage , fetchPypi, isPy3k, linuxPackages , fastrlock, numpy, six, wheel, pytest, mock, setuptools -, cudatoolkit, cudnn, nccl +, cudatoolkit, cudnn, cutensor, nccl }: buildPythonPackage rec { @@ -26,6 +26,7 @@ buildPythonPackage rec { propagatedBuildInputs = [ cudatoolkit cudnn + cutensor linuxPackages.nvidia_x11 nccl fastrlock diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index 1f3b5e682ba..67dee805518 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -1589,6 +1589,7 @@ in { cudatoolkit = pkgs.cudatoolkit_10_0; cudnn = pkgs.cudnn_cudatoolkit_10_0; nccl = pkgs.nccl_cudatoolkit_10; + cutensor = pkgs.cutensor_cudatoolkit_10; }; curio = callPackage ../development/python-modules/curio { }; From 66447439a012a3fa8a576367e2ec9bf7f1db75df Mon Sep 17 00:00:00 2001 From: John Ericson Date: Wed, 17 Mar 2021 18:44:46 -0400 Subject: [PATCH 4/4] maintainers-list: obsidian-systems-maintenance Fix mispelling. That word always breaks me... --- maintainers/maintainer-list.nix | 2 +- pkgs/development/libraries/science/math/cutensor/generic.nix | 2 +- pkgs/test/cuda/cuda-library-samples/generic.nix | 2 +- pkgs/test/cuda/cuda-samples/generic.nix | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/maintainers/maintainer-list.nix b/maintainers/maintainer-list.nix index 03a16d860b8..0f87b3d8641 100644 --- a/maintainers/maintainer-list.nix +++ b/maintainers/maintainer-list.nix @@ -6987,7 +6987,7 @@ githubId = 3359345; name = "obadz"; }; - obsidian-systems-maintainence = { + obsidian-systems-maintenance = { name = "Obsidian Systems Maintenance"; email = "maintainer@obsidian.systems"; github = "obsidian-systems-maintenance"; diff --git a/pkgs/development/libraries/science/math/cutensor/generic.nix b/pkgs/development/libraries/science/math/cutensor/generic.nix index 31b7dbdb8de..0b2bd31b2c3 100644 --- a/pkgs/development/libraries/science/math/cutensor/generic.nix +++ b/pkgs/development/libraries/science/math/cutensor/generic.nix @@ -64,6 +64,6 @@ stdenv.mkDerivation { homepage = "https://developer.nvidia.com/cutensor"; license = licenses.unfree; platforms = [ "x86_64-linux" ]; - maintainers = with maintainers; [ obsidian-systems-maintainence ]; + maintainers = with maintainers; [ obsidian-systems-maintenance ]; }; } diff --git a/pkgs/test/cuda/cuda-library-samples/generic.nix b/pkgs/test/cuda/cuda-library-samples/generic.nix index 999e2abd041..f1ce243bfa6 100644 --- a/pkgs/test/cuda/cuda-library-samples/generic.nix +++ b/pkgs/test/cuda/cuda-library-samples/generic.nix @@ -30,7 +30,7 @@ let cuSPARSE, cuSOLVER, cuFFT, cuRAND, NPP and nvJPEG. ''; license = lib.licenses.bsd3; - maintainers = with lib.maintainers; [ obsidian-systems-maintainence ]; + maintainers = with lib.maintainers; [ obsidian-systems-maintenance ]; }; }; in diff --git a/pkgs/test/cuda/cuda-samples/generic.nix b/pkgs/test/cuda/cuda-samples/generic.nix index a104f88ad4b..2e3dcc8891f 100644 --- a/pkgs/test/cuda/cuda-samples/generic.nix +++ b/pkgs/test/cuda/cuda-samples/generic.nix @@ -46,6 +46,6 @@ stdenv.mkDerivation { description = "Samples for CUDA Developers which demonstrates features in CUDA Toolkit"; # CUDA itself is proprietary, but these sample apps are not. license = lib.licenses.bsd3; - maintainers = with lib.maintainers; [ obsidian-systems-maintainence ]; + maintainers = with lib.maintainers; [ obsidian-systems-maintenance ]; }; }