nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at python-updates 121 lines 3.4 kB view raw
1{ 2 addDriverRunpath, 3 autoAddDriverRunpath, 4 autoPatchelfHook, 5 backendStdenv, 6 cmake, 7 cuda_cccl, 8 cuda_cudart, 9 cuda_nvcc, 10 cudatoolkit, 11 libcusparse_lt, 12 libcutensor, 13 fetchFromGitHub, 14 lib, 15 libcusparse, 16 setupCudaHook, 17}: 18let 19 base = backendStdenv.mkDerivation (finalAttrs: { 20 src = fetchFromGitHub { 21 owner = "NVIDIA"; 22 repo = "CUDALibrarySamples"; 23 rev = "e57b9c483c5384b7b97b7d129457e5a9bdcdb5e1"; 24 sha256 = "0g17afsmb8am0darxchqgjz1lmkaihmnn7k1x4ahg5gllcmw8k3l"; 25 }; 26 version = 27 lib.strings.substring 0 7 finalAttrs.src.rev + "-" + lib.versions.majorMinor cudatoolkit.version; 28 nativeBuildInputs = [ 29 cmake 30 addDriverRunpath 31 ]; 32 buildInputs = [ cudatoolkit ]; 33 postFixup = '' 34 for exe in $out/bin/*; do 35 addDriverRunpath $exe 36 done 37 ''; 38 meta = { 39 description = "examples of using libraries using CUDA"; 40 longDescription = '' 41 CUDA Library Samples contains examples demonstrating the use of 42 features in the math and image processing libraries cuBLAS, cuTENSOR, 43 cuSPARSE, cuSOLVER, cuFFT, cuRAND, NPP and nvJPEG. 44 ''; 45 license = lib.licenses.bsd3; 46 platforms = [ "x86_64-linux" ]; 47 teams = [ lib.teams.cuda ]; 48 }; 49 }); 50in 51 52{ 53 cublas = base.overrideAttrs ( 54 finalAttrs: _: { 55 pname = "cuda-library-samples-cublas"; 56 sourceRoot = "${finalAttrs.src.name}/cuBLASLt"; 57 } 58 ); 59 60 cusolver = base.overrideAttrs ( 61 finalAttrs: _: { 62 pname = "cuda-library-samples-cusolver"; 63 sourceRoot = "${finalAttrs.src.name}/cuSOLVER/gesv"; 64 } 65 ); 66 67 cutensor = base.overrideAttrs ( 68 finalAttrs: prevAttrs: { 69 pname = "cuda-library-samples-cutensor"; 70 71 sourceRoot = "${finalAttrs.src.name}/cuTENSOR"; 72 73 buildInputs = prevAttrs.buildInputs or [ ] ++ [ libcutensor ]; 74 75 cmakeFlags = prevAttrs.cmakeFlags or [ ] ++ [ 76 "-DCUTENSOR_EXAMPLE_BINARY_INSTALL_DIR=${placeholder "out"}/bin" 77 ]; 78 79 # CUTENSOR_ROOT is double escaped 80 postPatch = prevAttrs.postPatch or "" + '' 81 substituteInPlace CMakeLists.txt \ 82 --replace-fail "\''${CUTENSOR_ROOT}/include" "${lib.getOutput "include" libcutensor}/include" 83 ''; 84 85 CUTENSOR_ROOT = libcutensor; 86 } 87 ); 88 89 cusparselt = base.overrideAttrs ( 90 finalAttrs: prevAttrs: { 91 pname = "cuda-library-samples-cusparselt"; 92 93 sourceRoot = "${finalAttrs.src.name}/cuSPARSELt/matmul"; 94 95 nativeBuildInputs = prevAttrs.nativeBuildInputs or [ ] ++ [ 96 cmake 97 addDriverRunpath 98 (lib.getDev libcusparse_lt) 99 (lib.getDev libcusparse) 100 cuda_nvcc 101 (lib.getDev cuda_cudart) # <cuda_runtime_api.h> 102 cuda_cccl # <nv/target> 103 ]; 104 105 postPatch = prevAttrs.postPatch or "" + '' 106 substituteInPlace CMakeLists.txt \ 107 --replace-fail "''${CUSPARSELT_ROOT}/lib64/libcusparseLt.so" "${lib.getLib libcusparse_lt}/lib/libcusparseLt.so" \ 108 --replace-fail "''${CUSPARSELT_ROOT}/lib64/libcusparseLt_static.a" "${lib.getStatic libcusparse_lt}/lib/libcusparseLt_static.a" 109 ''; 110 111 postInstall = prevAttrs.postInstall or "" + '' 112 mkdir -p $out/bin 113 cp matmul_example $out/bin/ 114 cp matmul_example_static $out/bin/ 115 ''; 116 117 CUDA_TOOLKIT_PATH = lib.getLib cudatoolkit; 118 CUSPARSELT_PATH = lib.getLib libcusparse_lt; 119 } 120 ); 121}