lol

Merge pull request #221390 from NixOS/uri/jax

python3Packages.jaxlib-build: share fetch derivation between different build derivations

authored by

Samuel Ainsworth and committed by
GitHub
2d79f0cc 73869ed2

+74 -59
+74 -59
pkgs/development/python-modules/jaxlib/default.nix
··· 86 86 ]; 87 87 }; 88 88 89 - bazel-build = buildBazelPackage { 89 + # Copy-paste from TF derivation. 90 + # Most of these are not really used in jaxlib compilation but it's simpler to keep it 91 + # 'as is' so that it's more compatible with TF derivation. 92 + tf_system_libs = [ 93 + "absl_py" 94 + "astor_archive" 95 + "astunparse_archive" 96 + "boringssl" 97 + # Not packaged in nixpkgs 98 + # "com_github_googleapis_googleapis" 99 + # "com_github_googlecloudplatform_google_cloud_cpp" 100 + "com_github_grpc_grpc" 101 + "com_google_protobuf" 102 + # Fails with the error: external/org_tensorflow/tensorflow/core/profiler/utils/tf_op_utils.cc:46:49: error: no matching function for call to 're2::RE2::FullMatch(absl::lts_2020_02_25::string_view&, re2::RE2&)' 103 + # "com_googlesource_code_re2" 104 + "curl" 105 + "cython" 106 + "dill_archive" 107 + "double_conversion" 108 + "flatbuffers" 109 + "functools32_archive" 110 + "gast_archive" 111 + "gif" 112 + "hwloc" 113 + "icu" 114 + "jsoncpp_git" 115 + "libjpeg_turbo" 116 + "lmdb" 117 + "nasm" 118 + "opt_einsum_archive" 119 + "org_sqlite" 120 + "pasta" 121 + "png" 122 + "pybind11" 123 + "six_archive" 124 + "snappy" 125 + "tblib_archive" 126 + "termcolor_archive" 127 + "typing_extensions_archive" 128 + "wrapt" 129 + "zlib" 130 + ]; 131 + 132 + bazel-build = buildBazelPackage rec { 90 133 name = "bazel-build-${pname}-${version}"; 91 134 92 135 bazel = bazel_5; ··· 169 212 CFG 170 213 ''; 171 214 172 - # Copy-paste from TF derivation. 173 - # Most of these are not really used in jaxlib compilation but it's simpler to keep it 174 - # 'as is' so that it's more compatible with TF derivation. 175 - TF_SYSTEM_LIBS = lib.concatStringsSep "," ([ 176 - "absl_py" 177 - "astor_archive" 178 - "astunparse_archive" 179 - "boringssl" 180 - # Not packaged in nixpkgs 181 - # "com_github_googleapis_googleapis" 182 - # "com_github_googlecloudplatform_google_cloud_cpp" 183 - "com_github_grpc_grpc" 184 - "com_google_protobuf" 185 - # Fails with the error: external/org_tensorflow/tensorflow/core/profiler/utils/tf_op_utils.cc:46:49: error: no matching function for call to 're2::RE2::FullMatch(absl::lts_2020_02_25::string_view&, re2::RE2&)' 186 - # "com_googlesource_code_re2" 187 - "curl" 188 - "cython" 189 - "dill_archive" 190 - "double_conversion" 191 - "flatbuffers" 192 - "functools32_archive" 193 - "gast_archive" 194 - "gif" 195 - "hwloc" 196 - "icu" 197 - "jsoncpp_git" 198 - "libjpeg_turbo" 199 - "lmdb" 200 - "nasm" 201 - "opt_einsum_archive" 202 - "org_sqlite" 203 - "pasta" 204 - "png" 205 - "pybind11" 206 - "six_archive" 207 - "snappy" 208 - "tblib_archive" 209 - "termcolor_archive" 210 - "typing_extensions_archive" 211 - "wrapt" 212 - "zlib" 213 - ] ++ lib.optionals (!stdenv.isDarwin) [ 214 - "nsync" # fails to build on darwin 215 - ]); 216 - 217 215 # Make sure Bazel knows about our configuration flags during fetching so that the 218 216 # relevant dependencies can be downloaded. 219 217 bazelFlags = [ 220 218 "-c opt" 221 - ] ++ lib.optionals (stdenv.targetPlatform.isx86_64 && stdenv.targetPlatform.isUnix) [ 222 - "--config=avx_posix" 223 - ] ++ lib.optionals cudaSupport [ 224 - "--config=cuda" 225 - ] ++ lib.optionals mklSupport [ 226 - "--config=mkl_open_source_only" 227 219 ] ++ lib.optionals stdenv.cc.isClang [ 228 220 # bazel depends on the compiler frontend automatically selecting these flags based on file 229 221 # extension but our clang doesn't. ··· 231 223 "--cxxopt=-x" "--cxxopt=c++" "--host_cxxopt=-x" "--host_cxxopt=c++" 232 224 ]; 233 225 226 + # We intentionally overfetch so we can share the fetch derivation across all the different configurations 234 227 fetchAttrs = { 228 + TF_SYSTEM_LIBS = lib.concatStringsSep "," tf_system_libs; 229 + # we have to force @mkl_dnn_v1 since it's not needed on darwin 230 + bazelTargets = bazelTargets ++ [ "@mkl_dnn_v1//:mkl_dnn" ]; 231 + bazelFlags = bazelFlags ++ [ 232 + "--config=avx_posix" 233 + ] ++ lib.optionals cudaSupport [ 234 + # ideally we'd add this unconditionally too, but it doesn't work on darwin 235 + # we make this conditional on `cudaSupport` instead of the system, so that the hash for both 236 + # the cuda and the non-cuda deps can be computed on linux, since a lot of contributors don't 237 + # have access to darwin machines 238 + "--config=cuda" 239 + ] ++ [ 240 + "--config=mkl_open_source_only" 241 + ]; 242 + 235 243 sha256 = 236 244 if cudaSupport then 237 - "sha256-n8wo+hD9ZYO1SsJKgyJzUmjRlsz45WT6tt5ZLleGvGY=" 238 - else { 239 - x86_64-linux = "sha256-A0A18kxgGNGHNQ67ZPUzh3Yq2LEcRV7CqR9EfP80NQk="; 240 - aarch64-linux = "sha256-mU2jzuDu89jVmaG/M5bA3jSd7n7lDi+h8sdhs1z8p1A="; 241 - x86_64-darwin = "sha256-9nNTpetvjyipD/l8vKlregl1j/OnZKAcOCoZQeRBvts="; 242 - aarch64-darwin = "sha256-FqYwI1YC5eqSv+DYj09DC5IaBfFDUCO97y+TFhGiWAA="; 243 - }.${stdenv.system} or (throw "unsupported system ${stdenv.system}"); 245 + "sha256-4yu4y4SwSQoeaOz9yojhvCRGSC6jp61ycVDIKyIK/l8=" 246 + else 247 + "sha256-CyRfPfJc600M7VzR3/SQX/EAyeaXRJwDQWot5h2XnFU="; 244 248 }; 245 249 246 250 buildAttrs = { 247 251 outputs = [ "out" ]; 248 252 253 + TF_SYSTEM_LIBS = lib.concatStringsSep "," (tf_system_libs ++ lib.optionals (!stdenv.isDarwin) [ 254 + "nsync" # fails to build on darwin 255 + ]); 256 + 257 + bazelFlags = bazelFlags ++ lib.optionals (stdenv.targetPlatform.isx86_64 && stdenv.targetPlatform.isUnix) [ 258 + "--config=avx_posix" 259 + ] ++ lib.optionals cudaSupport [ 260 + "--config=cuda" 261 + ] ++ lib.optionals mklSupport [ 262 + "--config=mkl_open_source_only" 263 + ]; 249 264 # Note: we cannot do most of this patching at `patch` phase as the deps are not available yet. 250 265 # 1) Fix pybind11 include paths. 251 266 # 2) Link protobuf from nixpkgs (through TF_SYSTEM_LIBS when using gcc) to prevent crashes on