nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
fork

Configure Feed

Select the types of activity you want to include in your feed.

python.pkgs.tensorflow{,-bin,-estimator,-tensorboard}-2: Init at 2.1.0

Major breaking change from 1.x, so treating keeping both versions for now.

(adapted from 33f11be707e39acf96423f97f3baa80d8f11a0cb)
(adapted from 9e8dea7986dbdde850a58c7704182776642d8919)

authored by

Timo Kaufmann and committed by
John Ericson
a730888c d4de62de

+843 -40
pkgs/development/python-modules/tensorflow-estimator/1_15_1.nix pkgs/development/python-modules/tensorflow-estimator/1/default.nix
pkgs/development/python-modules/tensorflow-estimator/default.nix pkgs/development/python-modules/tensorflow-estimator/2/default.nix
+68
pkgs/development/python-modules/tensorflow-tensorboard/2/default.nix
··· 1 + { lib, fetchPypi, buildPythonPackage, isPy3k 2 + , numpy 3 + , wheel 4 + , werkzeug 5 + , protobuf 6 + , grpcio 7 + , markdown 8 + , futures 9 + , absl-py 10 + , google-auth-oauthlib 11 + }: 12 + 13 + # tensorflow/tensorboard is built from a downloaded wheel, because 14 + # https://github.com/tensorflow/tensorboard/issues/719 blocks 15 + # buildBazelPackage. 16 + 17 + buildPythonPackage rec { 18 + pname = "tensorflow-tensorboard"; 19 + version = "2.1.0"; 20 + format = "wheel"; 21 + 22 + src = fetchPypi ({ 23 + pname = "tensorboard"; 24 + inherit version; 25 + format = "wheel"; 26 + } // (if isPy3k then { 27 + python = "py3"; 28 + sha256 = "1wpjdzhjpcdkyaahzd4bl71k4l30z5c55280ndiwj32hw70lxrp6"; 29 + } else { 30 + python = "py2"; 31 + sha256 = "1f805839xa36wxb7xac9fyxzaww92vw4d50vs6g61wnlr4byp00w"; 32 + })); 33 + 34 + propagatedBuildInputs = [ 35 + numpy 36 + werkzeug 37 + protobuf 38 + markdown 39 + grpcio 40 + absl-py 41 + google-auth-oauthlib 42 + # not declared in install_requires, but used at runtime 43 + # https://github.com/NixOS/nixpkgs/issues/73840 44 + wheel 45 + ] ++ lib.optional (!isPy3k) futures; 46 + 47 + # in the absence of a real test suite, run cli and imports 48 + checkPhase = '' 49 + $out/bin/tensorboard --help > /dev/null 50 + ''; 51 + 52 + pythonImportsCheck = [ 53 + "tensorboard" 54 + "tensorboard.backend" 55 + "tensorboard.compat" 56 + "tensorboard.data" 57 + "tensorboard.plugins" 58 + "tensorboard.summary" 59 + "tensorboard.util" 60 + ]; 61 + 62 + meta = with lib; { 63 + description = "TensorFlow's Visualization Toolkit"; 64 + homepage = http://tensorflow.org; 65 + license = licenses.asl20; 66 + maintainers = with maintainers; [ abbradar ]; 67 + }; 68 + }
pkgs/development/python-modules/tensorflow-tensorboard/default.nix pkgs/development/python-modules/tensorflow-tensorboard/1/default.nix
+430
pkgs/development/python-modules/tensorflow/1/default.nix
··· 1 + { stdenv, pkgs, bazel_0_26, buildBazelPackage, lib, fetchFromGitHub, fetchpatch, symlinkJoin 2 + , addOpenGLRunpath 3 + # Python deps 4 + , buildPythonPackage, isPy3k, isPy27, pythonOlder, pythonAtLeast, python 5 + # Python libraries 6 + , numpy, tensorflow-tensorboard_1, backports_weakref, mock, enum34, absl-py 7 + , future, setuptools, wheel, keras-preprocessing, keras-applications, google-pasta 8 + , functools32 9 + , opt-einsum 10 + , termcolor, grpcio, six, wrapt, protobuf, tensorflow-estimator_1 11 + # Common deps 12 + , git, swig, which, binutils, glibcLocales, cython 13 + # Common libraries 14 + , jemalloc, openmpi, astor, gast, grpc, sqlite, openssl, jsoncpp, re2 15 + , curl, snappy, flatbuffers, icu, double-conversion, libpng, libjpeg, giflib 16 + # Upsteam by default includes cuda support since tensorflow 1.15. We could do 17 + # that in nix as well. It would make some things easier and less confusing, but 18 + # it would also make the default tensorflow package unfree. See 19 + # https://groups.google.com/a/tensorflow.org/forum/#!topic/developers/iRCt5m4qUz0 20 + , cudaSupport ? false, nvidia_x11 ? null, cudatoolkit ? null, cudnn ? null, nccl ? null 21 + # XLA without CUDA is broken 22 + , xlaSupport ? cudaSupport 23 + # Default from ./configure script 24 + , cudaCapabilities ? [ "3.5" "5.2" ] 25 + , sse42Support ? builtins.elem (stdenv.hostPlatform.platform.gcc.arch or "default") ["westmere" "sandybridge" "ivybridge" "haswell" "broadwell" "skylake" "skylake-avx512"] 26 + , avx2Support ? builtins.elem (stdenv.hostPlatform.platform.gcc.arch or "default") [ "haswell" "broadwell" "skylake" "skylake-avx512"] 27 + , fmaSupport ? builtins.elem (stdenv.hostPlatform.platform.gcc.arch or "default") [ "haswell" "broadwell" "skylake" "skylake-avx512"] 28 + # Darwin deps 29 + , Foundation, Security 30 + }: 31 + 32 + assert cudaSupport -> nvidia_x11 != null 33 + && cudatoolkit != null 34 + && cudnn != null; 35 + 36 + # unsupported combination 37 + assert ! (stdenv.isDarwin && cudaSupport); 38 + 39 + let 40 + withTensorboard = pythonOlder "3.6"; 41 + 42 + cudatoolkit_joined = symlinkJoin { 43 + name = "${cudatoolkit.name}-merged"; 44 + paths = [ 45 + cudatoolkit.lib 46 + cudatoolkit.out 47 + # for some reason some of the required libs are in the targets/x86_64-linux 48 + # directory; not sure why but this works around it 49 + "${cudatoolkit}/targets/${stdenv.system}" 50 + ]; 51 + }; 52 + 53 + cudatoolkit_cc_joined = symlinkJoin { 54 + name = "${cudatoolkit.cc.name}-merged"; 55 + paths = [ 56 + cudatoolkit.cc 57 + binutils.bintools # for ar, dwp, nm, objcopy, objdump, strip 58 + ]; 59 + }; 60 + 61 + # Needed for _some_ system libraries, grep INCLUDEDIR. 62 + includes_joined = symlinkJoin { 63 + name = "tensorflow-deps-merged"; 64 + paths = [ 65 + pkgs.protobuf 66 + jsoncpp 67 + ]; 68 + }; 69 + 70 + tfFeature = x: if x then "1" else "0"; 71 + 72 + version = "1.15.2"; 73 + variant = if cudaSupport then "-gpu" else ""; 74 + pname = "tensorflow${variant}"; 75 + 76 + pythonEnv = python.withPackages (_: 77 + [ # python deps needed during wheel build time (not runtime, see the buildPythonPackage part for that) 78 + numpy 79 + keras-preprocessing 80 + protobuf 81 + wrapt 82 + gast 83 + astor 84 + absl-py 85 + termcolor 86 + keras-applications 87 + setuptools 88 + wheel 89 + ] ++ lib.optionals (!isPy3k) 90 + [ future 91 + functools32 92 + mock 93 + ]); 94 + 95 + bazel-build = buildBazelPackage { 96 + name = "${pname}-${version}"; 97 + bazel = bazel_0_26; 98 + 99 + src = fetchFromGitHub { 100 + owner = "tensorflow"; 101 + repo = "tensorflow"; 102 + rev = "v${version}"; 103 + sha256 = "1q0848drjvnaaa38dgns8knmpmkj5plzsc98j20m5ybv68s55w78"; 104 + }; 105 + 106 + patches = [ 107 + # Work around https://github.com/tensorflow/tensorflow/issues/24752 108 + ../no-saved-proto.patch 109 + # Fixes for NixOS jsoncpp 110 + ../system-jsoncpp.patch 111 + 112 + # https://github.com/tensorflow/tensorflow/pull/29673 113 + (fetchpatch { 114 + name = "fix-compile-with-cuda-and-mpi.patch"; 115 + url = "https://github.com/tensorflow/tensorflow/pull/29673/commits/498e35a3bfe38dd75cf1416a1a23c07c3b59e6af.patch"; 116 + sha256 = "1m2qmwv1ysqa61z6255xggwbq6mnxbig749bdvrhnch4zydxb4di"; 117 + }) 118 + (fetchpatch { 119 + name = "backport-pr-18950.patch"; 120 + url = "https://github.com/tensorflow/tensorflow/commit/73640aaec2ab0234d9fff138e3c9833695570c0a.patch"; 121 + sha256 = "1n9ypbrx36fc1kc9cz5b3p9qhg15xxhq4nz6ap3hwqba535nakfz"; 122 + }) 123 + 124 + (fetchpatch { 125 + # be compatible with gast >0.2 instead of only gast 0.2.2 126 + name = "gast-update.patch"; 127 + url = "https://github.com/tensorflow/tensorflow/commit/85751ad6c7f5fd12c6c79545d96896cba92fa8b4.patch"; 128 + sha256 = "077cpj0kzyqxzdya1dwh8df17zfzhqn7c685hx6iskvw2979zg2n"; 129 + }) 130 + ./lift-gast-restriction.patch 131 + 132 + # cuda 10.2 does not have "-bin2c-path" option anymore 133 + # https://github.com/tensorflow/tensorflow/issues/34429 134 + ../cuda-10.2-no-bin2c-path.patch 135 + ]; 136 + 137 + # On update, it can be useful to steal the changes from gentoo 138 + # https://gitweb.gentoo.org/repo/gentoo.git/tree/sci-libs/tensorflow 139 + 140 + nativeBuildInputs = [ 141 + swig which pythonEnv 142 + ] ++ lib.optional cudaSupport addOpenGLRunpath; 143 + 144 + buildInputs = [ 145 + jemalloc 146 + openmpi 147 + glibcLocales 148 + git 149 + 150 + # libs taken from system through the TF_SYS_LIBS mechanism 151 + # grpc 152 + sqlite 153 + openssl 154 + jsoncpp 155 + pkgs.protobuf 156 + curl 157 + snappy 158 + flatbuffers 159 + icu 160 + double-conversion 161 + libpng 162 + libjpeg 163 + giflib 164 + re2 165 + pkgs.lmdb 166 + ] ++ lib.optionals cudaSupport [ 167 + cudatoolkit 168 + cudnn 169 + nvidia_x11 170 + ] ++ lib.optionals stdenv.isDarwin [ 171 + Foundation 172 + Security 173 + ]; 174 + 175 + # arbitrarily set to the current latest bazel version, overly careful 176 + TF_IGNORE_MAX_BAZEL_VERSION = true; 177 + 178 + # Take as many libraries from the system as possible. Keep in sync with 179 + # list of valid syslibs in 180 + # https://github.com/tensorflow/tensorflow/blob/master/third_party/systemlibs/syslibs_configure.bzl 181 + TF_SYSTEM_LIBS = lib.concatStringsSep "," [ 182 + "absl_py" 183 + "astor_archive" 184 + "boringssl" 185 + # Not packaged in nixpkgs 186 + # "com_github_googleapis_googleapis" 187 + # "com_github_googlecloudplatform_google_cloud_cpp" 188 + "com_google_protobuf" 189 + "com_googlesource_code_re2" 190 + "curl" 191 + "cython" 192 + "double_conversion" 193 + "flatbuffers" 194 + "gast_archive" 195 + "gif_archive" 196 + # Lots of errors, requires an older version 197 + # "grpc" 198 + "hwloc" 199 + "icu" 200 + "jpeg" 201 + "jsoncpp_git" 202 + "keras_applications_archive" 203 + "lmdb" 204 + "nasm" 205 + # "nsync" # not packaged in nixpkgs 206 + "opt_einsum_archive" 207 + "org_sqlite" 208 + "pasta" 209 + "pcre" 210 + "png_archive" 211 + "six_archive" 212 + "snappy" 213 + "swig" 214 + "termcolor_archive" 215 + "wrapt" 216 + "zlib_archive" 217 + ]; 218 + 219 + INCLUDEDIR = "${includes_joined}/include"; 220 + 221 + PYTHON_BIN_PATH = pythonEnv.interpreter; 222 + 223 + TF_NEED_GCP = true; 224 + TF_NEED_HDFS = true; 225 + TF_ENABLE_XLA = tfFeature xlaSupport; 226 + 227 + CC_OPT_FLAGS = " "; 228 + 229 + # https://github.com/tensorflow/tensorflow/issues/14454 230 + TF_NEED_MPI = tfFeature cudaSupport; 231 + 232 + TF_NEED_CUDA = tfFeature cudaSupport; 233 + TF_CUDA_PATHS = lib.optionalString cudaSupport "${cudatoolkit_joined},${cudnn},${nccl}"; 234 + GCC_HOST_COMPILER_PREFIX = lib.optionalString cudaSupport "${cudatoolkit_cc_joined}/bin"; 235 + GCC_HOST_COMPILER_PATH = lib.optionalString cudaSupport "${cudatoolkit_cc_joined}/bin/gcc"; 236 + TF_CUDA_COMPUTE_CAPABILITIES = lib.concatStringsSep "," cudaCapabilities; 237 + 238 + postPatch = '' 239 + # https://github.com/tensorflow/tensorflow/issues/20919 240 + sed -i '/androidndk/d' tensorflow/lite/kernels/internal/BUILD 241 + 242 + # Tensorboard pulls in a bunch of dependencies, some of which may 243 + # include security vulnerabilities. So we make it optional. 244 + # https://github.com/tensorflow/tensorflow/issues/20280#issuecomment-400230560 245 + sed -i '/tensorboard >=/d' tensorflow/tools/pip_package/setup.py 246 + ''; 247 + 248 + preConfigure = let 249 + opt_flags = [] 250 + ++ lib.optionals sse42Support ["-msse4.2"] 251 + ++ lib.optionals avx2Support ["-mavx2"] 252 + ++ lib.optionals fmaSupport ["-mfma"]; 253 + in '' 254 + patchShebangs configure 255 + 256 + # dummy ldconfig 257 + mkdir dummy-ldconfig 258 + echo "#!${stdenv.shell}" > dummy-ldconfig/ldconfig 259 + chmod +x dummy-ldconfig/ldconfig 260 + export PATH="$PWD/dummy-ldconfig:$PATH" 261 + 262 + export PYTHON_LIB_PATH="$NIX_BUILD_TOP/site-packages" 263 + export CC_OPT_FLAGS="${lib.concatStringsSep " " opt_flags}" 264 + mkdir -p "$PYTHON_LIB_PATH" 265 + 266 + # To avoid mixing Python 2 and Python 3 267 + unset PYTHONPATH 268 + ''; 269 + 270 + configurePhase = '' 271 + runHook preConfigure 272 + ./configure 273 + runHook postConfigure 274 + ''; 275 + 276 + # FIXME: Tensorflow uses dlopen() for CUDA libraries. 277 + NIX_LDFLAGS = lib.optionalString cudaSupport "-lcudart -lcublas -lcufft -lcurand -lcusolver -lcusparse -lcudnn"; 278 + 279 + hardeningDisable = [ "format" ]; 280 + 281 + bazelFlags = [ 282 + # temporary fixes to make the build work with bazel 0.27 283 + "--incompatible_no_support_tools_in_action_inputs=false" 284 + ]; 285 + bazelBuildFlags = [ 286 + "--config=opt" # optimize using the flags set in the configure phase 287 + ]; 288 + 289 + bazelTarget = "//tensorflow/tools/pip_package:build_pip_package //tensorflow/tools/lib_package:libtensorflow"; 290 + 291 + fetchAttrs = { 292 + # So that checksums don't depend on these. 293 + TF_SYSTEM_LIBS = null; 294 + 295 + # cudaSupport causes fetch of ncclArchive, resulting in different hashes 296 + sha256 = if cudaSupport then 297 + "1qygfcvvn9vysap9nk6xccxi9mgmzyxiywz6k456f811l1v70p2c" 298 + else 299 + "0kfjanw0mfbh30vi1ms2xlg8yp429cbyfriik6yxd5cla2pncg2j"; 300 + }; 301 + 302 + buildAttrs = { 303 + outputs = [ "out" "python" ]; 304 + 305 + preBuild = '' 306 + patchShebangs . 307 + ''; 308 + 309 + installPhase = '' 310 + mkdir -p "$out" 311 + tar -xf bazel-bin/tensorflow/tools/lib_package/libtensorflow.tar.gz -C "$out" 312 + # Write pkgconfig file. 313 + mkdir "$out/lib/pkgconfig" 314 + cat > "$out/lib/pkgconfig/tensorflow.pc" << EOF 315 + Name: TensorFlow 316 + Version: ${version} 317 + Description: Library for computation using data flow graphs for scalable machine learning 318 + Requires: 319 + Libs: -L$out/lib -ltensorflow 320 + Cflags: -I$out/include/tensorflow 321 + EOF 322 + 323 + # build the source code, then copy it to $python (build_pip_package 324 + # actually builds a symlink farm so we must dereference them). 325 + bazel-bin/tensorflow/tools/pip_package/build_pip_package --src "$PWD/dist" 326 + cp -Lr "$PWD/dist" "$python" 327 + ''; 328 + 329 + postFixup = lib.optionalString cudaSupport '' 330 + find $out -type f \( -name '*.so' -or -name '*.so.*' \) | while read lib; do 331 + addOpenGLRunpath "$lib" 332 + done 333 + ''; 334 + }; 335 + 336 + meta = with stdenv.lib; { 337 + description = "Computation using data flow graphs for scalable machine learning"; 338 + homepage = http://tensorflow.org; 339 + license = licenses.asl20; 340 + maintainers = with maintainers; [ jyp abbradar ]; 341 + platforms = with platforms; linux ++ darwin; 342 + # The py2 build fails due to some issue importing protobuf. Possibly related to the fix in 343 + # https://github.com/akesandgren/easybuild-easyblocks/commit/1f2e517ddfd1b00a342c6abb55aef3fd93671a2b 344 + broken = !(xlaSupport -> cudaSupport) || !isPy3k; 345 + }; 346 + }; 347 + 348 + in buildPythonPackage { 349 + inherit version pname; 350 + disabled = isPy27 || (pythonAtLeast "3.8"); 351 + 352 + src = bazel-build.python; 353 + 354 + # Upstream has a pip hack that results in bin/tensorboard being in both tensorflow 355 + # and the propagated input tensorflow-tensorboard, which causes environment collisions. 356 + # Another possibility would be to have tensorboard only in the buildInputs 357 + # https://github.com/tensorflow/tensorflow/blob/v1.7.1/tensorflow/tools/pip_package/setup.py#L79 358 + postInstall = '' 359 + rm $out/bin/tensorboard 360 + ''; 361 + 362 + setupPyGlobalFlags = [ "--project_name ${pname}" ]; 363 + 364 + # tensorflow/tools/pip_package/setup.py 365 + propagatedBuildInputs = [ 366 + absl-py 367 + astor 368 + gast 369 + google-pasta 370 + keras-applications 371 + keras-preprocessing 372 + numpy 373 + six 374 + protobuf 375 + tensorflow-estimator_1 376 + termcolor 377 + wrapt 378 + grpcio 379 + opt-einsum 380 + ] ++ lib.optionals (!isPy3k) [ 381 + mock 382 + future 383 + functools32 384 + ] ++ lib.optionals (pythonOlder "3.4") [ 385 + backports_weakref enum34 386 + ] ++ lib.optionals withTensorboard [ 387 + tensorflow-tensorboard_1 388 + ]; 389 + 390 + nativeBuildInputs = lib.optional cudaSupport addOpenGLRunpath; 391 + 392 + postFixup = lib.optionalString cudaSupport '' 393 + find $out -type f \( -name '*.so' -or -name '*.so.*' \) | while read lib; do 394 + addOpenGLRunpath "$lib" 395 + done 396 + ''; 397 + 398 + # Actual tests are slow and impure. 399 + # TODO try to run them anyway 400 + # TODO better test (files in tensorflow/tools/ci_build/builds/*test) 401 + checkPhase = '' 402 + ${python.interpreter} <<EOF 403 + # A simple "Hello world" 404 + import tensorflow as tf 405 + hello = tf.constant("Hello, world!") 406 + sess = tf.Session() 407 + sess.run(hello) 408 + 409 + # Fit a simple model to random data 410 + import numpy as np 411 + np.random.seed(0) 412 + tf.random.set_random_seed(0) 413 + model = tf.keras.models.Sequential([ 414 + tf.keras.layers.Dense(1, activation="linear") 415 + ]) 416 + model.compile(optimizer="sgd", loss="mse") 417 + 418 + x = np.random.uniform(size=(1,1)) 419 + y = np.random.uniform(size=(1,)) 420 + model.fit(x, y, epochs=1) 421 + 422 + # regression test for #77626 423 + from tensorflow.contrib import tensor_forest 424 + EOF 425 + ''; 426 + 427 + passthru.libtensorflow = bazel-build.out; 428 + 429 + inherit (bazel-build) meta; 430 + }
+179
pkgs/development/python-modules/tensorflow/2/bin.nix
··· 1 + { stdenv 2 + , lib 3 + , fetchurl 4 + , buildPythonPackage 5 + , isPy3k, pythonOlder, isPy38 6 + , astor 7 + , gast 8 + , google-pasta 9 + , wrapt 10 + , numpy 11 + , six 12 + , termcolor 13 + , protobuf 14 + , absl-py 15 + , grpcio 16 + , mock 17 + , scipy 18 + , wheel 19 + , opt-einsum 20 + , backports_weakref 21 + , tensorflow-estimator_2 22 + , tensorflow-tensorboard 23 + , cudaSupport ? false 24 + , cudatoolkit ? null 25 + , cudnn ? null 26 + , nvidia_x11 ? null 27 + , zlib 28 + , python 29 + , symlinkJoin 30 + , keras-applications 31 + , keras-preprocessing 32 + , addOpenGLRunpath 33 + }: 34 + 35 + # We keep this binary build for two reasons: 36 + # - the source build doesn't work on Darwin. 37 + # - the source build is currently brittle and not easy to maintain 38 + 39 + assert cudaSupport -> cudatoolkit != null 40 + && cudnn != null 41 + && nvidia_x11 != null; 42 + 43 + # unsupported combination 44 + assert ! (stdenv.isDarwin && cudaSupport); 45 + 46 + let 47 + packages = import ./binary-hashes.nix; 48 + 49 + variant = if cudaSupport then "-gpu" else ""; 50 + pname = "tensorflow${variant}"; 51 + 52 + in buildPythonPackage { 53 + inherit pname; 54 + inherit (packages) version; 55 + format = "wheel"; 56 + 57 + disabled = isPy38; 58 + 59 + src = let 60 + pyVerNoDot = lib.strings.stringAsChars (x: if x == "." then "" else x) python.pythonVersion; 61 + platform = if stdenv.isDarwin then "mac" else "linux"; 62 + unit = if cudaSupport then "gpu" else "cpu"; 63 + key = "${platform}_py_${pyVerNoDot}_${unit}"; 64 + in fetchurl packages.${key}; 65 + 66 + propagatedBuildInputs = [ 67 + protobuf 68 + numpy 69 + scipy 70 + termcolor 71 + grpcio 72 + six 73 + astor 74 + absl-py 75 + gast 76 + opt-einsum 77 + google-pasta 78 + wrapt 79 + tensorflow-estimator_2 80 + tensorflow-tensorboard 81 + keras-applications 82 + keras-preprocessing 83 + ] ++ lib.optional (!isPy3k) mock 84 + ++ lib.optionals (pythonOlder "3.4") [ backports_weakref ]; 85 + 86 + nativeBuildInputs = [ wheel ] ++ lib.optional cudaSupport addOpenGLRunpath; 87 + 88 + preConfigure = '' 89 + unset SOURCE_DATE_EPOCH 90 + 91 + # Make sure that dist and the wheel file are writable. 92 + chmod u+rwx -R ./dist 93 + 94 + pushd dist 95 + 96 + # Unpack the wheel file. 97 + wheel unpack --dest unpacked ./*.whl 98 + 99 + # Tensorflow has a hard dependency on gast==0.2.2, but we relax it to 100 + # gast==0.3.2. 101 + substituteInPlace ./unpacked/tensorflow*/tensorflow_core/tools/pip_package/setup.py --replace "gast == 0.2.2" "gast == 0.3.2" 102 + substituteInPlace ./unpacked/tensorflow*/tensorflow_*.dist-info/METADATA --replace "gast (==0.2.2)" "gast (==0.3.2)" 103 + 104 + # Pack the wheel file back up. 105 + wheel pack ./unpacked/tensorflow* 106 + 107 + popd 108 + ''; 109 + 110 + # Note that we need to run *after* the fixup phase because the 111 + # libraries are loaded at runtime. If we run in preFixup then 112 + # patchelf --shrink-rpath will remove the cuda libraries. 113 + postFixup = 114 + let 115 + # rpaths we only need to add if CUDA is enabled. 116 + cudapaths = lib.optionals cudaSupport [ 117 + cudatoolkit.out 118 + cudatoolkit.lib 119 + cudnn 120 + nvidia_x11 121 + ]; 122 + 123 + libpaths = [ 124 + stdenv.cc.cc.lib 125 + zlib 126 + ]; 127 + 128 + rpath = stdenv.lib.makeLibraryPath (libpaths ++ cudapaths); 129 + in 130 + lib.optionalString stdenv.isLinux '' 131 + # This is an array containing all the directories in the tensorflow2 132 + # package that contain .so files. 133 + # 134 + # TODO: Create this list programmatically, and remove paths that aren't 135 + # actually needed. 136 + rrPathArr=( 137 + "$out/${python.sitePackages}/tensorflow_core/" 138 + "$out/${python.sitePackages}/tensorflow_core/compiler/tf2tensorrt/" 139 + "$out/${python.sitePackages}/tensorflow_core/compiler/tf2xla/ops/" 140 + "$out/${python.sitePackages}/tensorflow_core/lite/experimental/microfrontend/python/ops/" 141 + "$out/${python.sitePackages}/tensorflow_core/lite/python/interpreter_wrapper/" 142 + "$out/${python.sitePackages}/tensorflow_core/lite/python/optimize/" 143 + "$out/${python.sitePackages}/tensorflow_core/python/" 144 + "$out/${python.sitePackages}/tensorflow_core/python/framework/" 145 + "${rpath}" 146 + ) 147 + 148 + # The the bash array into a colon-separated list of RPATHs. 149 + rrPath=$(IFS=$':'; echo "''${rrPathArr[*]}") 150 + echo "about to run patchelf with the following rpath: $rrPath" 151 + 152 + find $out -type f \( -name '*.so' -or -name '*.so.*' \) | while read lib; do 153 + echo "about to patchelf $lib..." 154 + chmod a+rx "$lib" 155 + patchelf --set-rpath "$rrPath" "$lib" 156 + ${lib.optionalString cudaSupport '' 157 + addOpenGLRunpath "$lib" 158 + ''} 159 + done 160 + ''; 161 + 162 + pythonImportsCheck = [ 163 + "tensorflow" 164 + "tensorflow.keras" 165 + "tensorflow.python" 166 + "tensorflow.python.framework" 167 + ]; 168 + 169 + meta = with stdenv.lib; { 170 + description = "Computation using data flow graphs for scalable machine learning"; 171 + homepage = http://tensorflow.org; 172 + license = licenses.asl20; 173 + maintainers = with maintainers; [ jyp abbradar cdepillabout ]; 174 + platforms = [ "x86_64-linux" "x86_64-darwin" ]; 175 + # Python 2.7 build uses different string encoding. 176 + # See https://github.com/NixOS/nixpkgs/pull/37044#issuecomment-373452253 177 + broken = stdenv.isDarwin && !isPy3k; 178 + }; 179 + }
+51
pkgs/development/python-modules/tensorflow/2/binary-hashes.nix
··· 1 + { 2 + version = "2.1.0"; 3 + linux_py_27_gpu = { 4 + url = "https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow_gpu-2.1.0-cp27-cp27mu-manylinux2010_x86_64.whl"; 5 + sha256 = "17lnhr7vdrls68c79n3sah5rpd0q1x2v5m84azvlyxxh2wpypfmb"; 6 + }; 7 + linux_py_27_cpu = { 8 + url = "https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow_cpu-2.1.0-cp27-cp27mu-manylinux2010_x86_64.whl"; 9 + sha256 = "10lz3i4pcpgqrcbjmxm0n7k1gsqlpna3kdid902j2fy060cpi93z"; 10 + }; 11 + linux_py_35_gpu = { 12 + url = "https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow_gpu-2.1.0-cp35-cp35m-manylinux2010_x86_64.whl"; 13 + sha256 = "09s081n08dpmflwgir3zwzfijfpmahbh2gy5fn5bv5ll86g1szsy"; 14 + }; 15 + linux_py_35_cpu = { 16 + url = "https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow_cpu-2.1.0-cp35-cp35m-manylinux2010_x86_64.whl"; 17 + sha256 = "1aa7v9fnvx03hqvhl3x3xcn41qy6qxw5xybg54ifjvvicp455c8l"; 18 + }; 19 + linux_py_36_gpu = { 20 + url = "https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow_gpu-2.1.0-cp36-cp36m-manylinux2010_x86_64.whl"; 21 + sha256 = "1dqp080ljbl9v3115vjp63ls0fimiwym6zxyanyhrlk8kwsq20zc"; 22 + }; 23 + linux_py_36_cpu = { 24 + url = "https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow_cpu-2.1.0-cp36-cp36m-manylinux2010_x86_64.whl"; 25 + sha256 = "133z8anx7xm9rr5i9s9dwnp1wf06nr6s7q1lbs4lxpk6kn9nl480"; 26 + }; 27 + linux_py_37_gpu = { 28 + url = "https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow_gpu-2.1.0-cp37-cp37m-manylinux2010_x86_64.whl"; 29 + sha256 = "0yabl3xmcpr67w0zksqs3qc68nl9ax0vcd7w7b35nq8f65xl0ghy"; 30 + }; 31 + linux_py_37_cpu = { 32 + url = "https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow_cpu-2.1.0-cp37-cp37m-manylinux2010_x86_64.whl"; 33 + sha256 = "04gngbngyg7p1gwx1q89my0cl8j7lq4kknqh51s2ynrix71zvsy6"; 34 + }; 35 + mac_py_27_cpu = { 36 + url = "https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-2.1.0-cp27-cp27m-macosx_10_9_x86_64.whl"; 37 + sha256 = "1mprp72w5kk0lyjm2mh4lf57827xk3wsg28c4gizwm00ydfgacg6"; 38 + }; 39 + mac_py_35_cpu = { 40 + url = "https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-2.1.0-cp35-cp35m-macosx_10_6_intel.whl"; 41 + sha256 = "1as7brf5ai6r7v1di9646jfrbnirpk2b0d1g29mn3shavb62kw8w"; 42 + }; 43 + mac_py_36_cpu = { 44 + url = "https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-2.1.0-cp36-cp36m-macosx_10_9_x86_64.whl"; 45 + sha256 = "1v1rw9kjrskhcq1yas4ly2yfnzf2i1pjh6qg6zixfbkpkw7sw3wc"; 46 + }; 47 + mac_py_37_cpu = { 48 + url = "https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-2.1.0-cp37-cp37m-macosx_10_9_x86_64.whl"; 49 + sha256 = "1hh4n0d97mrq35cmmsrnlmcv9vlswsyjy368lj3pda3y9dvck3rf"; 50 + }; 51 + }
+11
pkgs/development/python-modules/tensorflow/2/lift-gast-restriction.patch
··· 1 + diff --git a/tensorflow/tools/pip_package/setup.py b/tensorflow/tools/pip_package/setup.py 2 + index 992f2eae22..d9386f9b13 100644 3 + --- a/tensorflow/tools/pip_package/setup.py 4 + +++ b/tensorflow/tools/pip_package/setup.py 5 + @@ -54,5 +54,5 @@ REQUIRED_PACKAGES = [ 6 + 'enum34 >= 1.1.6;python_version<"3.4"', 7 + - 'gast == 0.2.2', 8 + + 'gast >= 0.2.2', 9 + 'google_pasta >= 0.1.6', 10 + 'keras_applications >= 1.0.8', 11 + 'keras_preprocessing >= 1.0.5',
+44
pkgs/development/python-modules/tensorflow/2/prefetcher.sh
··· 1 + #!/usr/bin/env bash 2 + 3 + version=2.1.0 4 + 5 + # List of binary wheels for Tensorflow. The most recent versions can be found 6 + # on the following page: 7 + # https://www.tensorflow.org/install/pip?lang=python3#package-location 8 + url_and_key_list=( 9 + "linux_py_27_gpu https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow_gpu-${version}-cp27-cp27mu-manylinux2010_x86_64.whl" 10 + "linux_py_27_cpu https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow_cpu-${version}-cp27-cp27mu-manylinux2010_x86_64.whl" 11 + "linux_py_35_gpu https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow_gpu-${version}-cp35-cp35m-manylinux2010_x86_64.whl" 12 + "linux_py_35_cpu https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow_cpu-${version}-cp35-cp35m-manylinux2010_x86_64.whl" 13 + "linux_py_36_gpu https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow_gpu-${version}-cp36-cp36m-manylinux2010_x86_64.whl" 14 + "linux_py_36_cpu https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow_cpu-${version}-cp36-cp36m-manylinux2010_x86_64.whl" 15 + "linux_py_37_gpu https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow_gpu-${version}-cp37-cp37m-manylinux2010_x86_64.whl" 16 + "linux_py_37_cpu https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow_cpu-${version}-cp37-cp37m-manylinux2010_x86_64.whl" 17 + "mac_py_27_cpu https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-${version}-cp27-cp27m-macosx_10_9_x86_64.whl" 18 + "mac_py_35_cpu https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-${version}-cp35-cp35m-macosx_10_6_intel.whl" 19 + "mac_py_36_cpu https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-${version}-cp36-cp36m-macosx_10_9_x86_64.whl" 20 + "mac_py_37_cpu https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-${version}-cp37-cp37m-macosx_10_9_x86_64.whl" 21 + ) 22 + 23 + hashfile=binary-hashes.nix 24 + rm -f $hashfile 25 + echo "{" >> $hashfile 26 + echo "version = \"$version\";" >> $hashfile 27 + 28 + for url_and_key in "${url_and_key_list[@]}"; do 29 + key=$(echo "$url_and_key" | cut -d' ' -f1) 30 + url=$(echo "$url_and_key" | cut -d' ' -f2) 31 + 32 + echo "prefetching ${url}..." 33 + hash=$(nix-prefetch-url $url) 34 + 35 + echo "$key = {" >> $hashfile 36 + echo " url = \"$url\";" >> $hashfile 37 + echo " sha256 = \"$hash\";" >> $hashfile 38 + echo "};" >> $hashfile 39 + 40 + echo 41 + done 42 + 43 + echo "}" >> $hashfile 44 + echo "done."
+2 -2
pkgs/development/python-modules/tensorflow/bin.nix pkgs/development/python-modules/tensorflow/1/bin.nix
··· 15 15 , grpcio 16 16 , mock 17 17 , backports_weakref 18 - , tensorflow-estimator 18 + , tensorflow-estimator_1 19 19 , tensorflow-tensorboard 20 20 , cudaSupport ? false 21 21 , cudatoolkit ? null ··· 72 72 gast 73 73 google-pasta 74 74 wrapt 75 - tensorflow-estimator 75 + tensorflow-estimator_1 76 76 tensorflow-tensorboard 77 77 keras-applications 78 78 keras-preprocessing
pkgs/development/python-modules/tensorflow/binary-hashes.nix pkgs/development/python-modules/tensorflow/1/binary-hashes.nix
+22 -32
pkgs/development/python-modules/tensorflow/default.nix pkgs/development/python-modules/tensorflow/2/default.nix
··· 1 - { stdenv, pkgs, bazel_0_26, buildBazelPackage, lib, fetchFromGitHub, fetchpatch, symlinkJoin 1 + { stdenv, pkgs, bazel_0_29, buildBazelPackage, lib, fetchFromGitHub, fetchpatch, symlinkJoin 2 2 , addOpenGLRunpath 3 3 # Python deps 4 4 , buildPythonPackage, isPy3k, isPy27, pythonOlder, pythonAtLeast, python 5 5 # Python libraries 6 - , numpy, tensorflow-tensorboard, backports_weakref, mock, enum34, absl-py 6 + , numpy, tensorflow-tensorboard_2, backports_weakref, mock, enum34, absl-py 7 7 , future, setuptools, wheel, keras-preprocessing, keras-applications, google-pasta 8 8 , functools32 9 9 , opt-einsum 10 - , termcolor, grpcio, six, wrapt, protobuf, tensorflow-estimator_1_15_1 10 + , termcolor, grpcio, six, wrapt, protobuf, tensorflow-estimator_2 11 11 # Common deps 12 12 , git, swig, which, binutils, glibcLocales, cython 13 13 # Common libraries ··· 69 69 70 70 tfFeature = x: if x then "1" else "0"; 71 71 72 - version = "1.15.2"; 72 + version = "2.1.0"; 73 73 variant = if cudaSupport then "-gpu" else ""; 74 74 pname = "tensorflow${variant}"; 75 75 ··· 94 94 95 95 bazel-build = buildBazelPackage { 96 96 name = "${pname}-${version}"; 97 - bazel = bazel_0_26; 97 + bazel = bazel_0_29; 98 98 99 99 src = fetchFromGitHub { 100 100 owner = "tensorflow"; 101 101 repo = "tensorflow"; 102 102 rev = "v${version}"; 103 - sha256 = "1q0848drjvnaaa38dgns8knmpmkj5plzsc98j20m5ybv68s55w78"; 103 + sha256 = "1g79xi8yl4sjia8ysk9b7xfzrz83zy28v5dlb2wzmcf0k5pmz60p"; 104 104 }; 105 105 106 106 patches = [ 107 107 # Work around https://github.com/tensorflow/tensorflow/issues/24752 108 - ./no-saved-proto.patch 108 + ../no-saved-proto.patch 109 109 # Fixes for NixOS jsoncpp 110 - ./system-jsoncpp.patch 110 + ../system-jsoncpp.patch 111 111 112 - # https://github.com/tensorflow/tensorflow/pull/29673 113 - (fetchpatch { 114 - name = "fix-compile-with-cuda-and-mpi.patch"; 115 - url = "https://github.com/tensorflow/tensorflow/pull/29673/commits/498e35a3bfe38dd75cf1416a1a23c07c3b59e6af.patch"; 116 - sha256 = "1m2qmwv1ysqa61z6255xggwbq6mnxbig749bdvrhnch4zydxb4di"; 117 - }) 118 112 (fetchpatch { 119 113 name = "backport-pr-18950.patch"; 120 114 url = "https://github.com/tensorflow/tensorflow/commit/73640aaec2ab0234d9fff138e3c9833695570c0a.patch"; 121 115 sha256 = "1n9ypbrx36fc1kc9cz5b3p9qhg15xxhq4nz6ap3hwqba535nakfz"; 122 116 }) 123 117 124 - 125 118 (fetchpatch { 126 - # be compatible with gast >0.2 instead of only gast 0.2.2 127 - name = "gast-update.patch"; 128 - url = "https://github.com/tensorflow/tensorflow/commit/85751ad6c7f5fd12c6c79545d96896cba92fa8b4.patch"; 129 - sha256 = "077cpj0kzyqxzdya1dwh8df17zfzhqn7c685hx6iskvw2979zg2n"; 119 + # Don't try to fetch things that don't exist 120 + name = "prune-missing-deps.patch"; 121 + url = "https://github.com/tensorflow/tensorflow/commit/b39b1ed24b4814db27d2f748dc85c10730ae851d.patch"; 122 + sha256 = "1skysz53nancvw1slij6s7flar2kv3gngnsq60ff4lap88kx5s6c"; 123 + excludes = [ "tensorflow/cc/saved_model/BUILD" ]; 130 124 }) 125 + 131 126 ./lift-gast-restriction.patch 132 127 133 128 # cuda 10.2 does not have "-bin2c-path" option anymore 134 129 # https://github.com/tensorflow/tensorflow/issues/34429 135 - ./cuda-10.2-no-bin2c-path.patch 130 + ../cuda-10.2-no-bin2c-path.patch 136 131 ]; 137 132 138 133 # On update, it can be useful to steal the changes from gentoo ··· 188 193 "double_conversion" 189 194 "flatbuffers" 190 195 "gast_archive" 191 - "gif_archive" 192 196 # Lots of errors, requires an older version 193 197 # "grpc" 194 198 "hwloc" ··· 202 208 "org_sqlite" 203 209 "pasta" 204 210 "pcre" 205 - "png_archive" 206 211 "six_archive" 207 212 "snappy" 208 213 "swig" ··· 288 295 289 296 # cudaSupport causes fetch of ncclArchive, resulting in different hashes 290 297 sha256 = if cudaSupport then 291 - "1qygfcvvn9vysap9nk6xccxi9mgmzyxiywz6k456f811l1v70p2c" 298 + "0hg3ysy644950a34j28hrb317cz8gcbb9n84d36wdailvnlshghb" 292 299 else 293 - "0kfjanw0mfbh30vi1ms2xlg8yp429cbyfriik6yxd5cla2pncg2j"; 300 + "1gy4pz9kn30wb9c4a9584fibb88c3h38y3dqa99yw1lbsbyyi28c"; 294 301 }; 295 302 296 303 buildAttrs = { ··· 366 373 numpy 367 374 six 368 375 protobuf 369 - tensorflow-estimator_1_15_1 376 + tensorflow-estimator_2 370 377 termcolor 371 378 wrapt 372 379 grpcio ··· 378 385 ] ++ lib.optionals (pythonOlder "3.4") [ 379 386 backports_weakref enum34 380 387 ] ++ lib.optionals withTensorboard [ 381 - tensorflow-tensorboard 388 + tensorflow-tensorboard_2 382 389 ]; 383 390 384 391 nativeBuildInputs = lib.optional cudaSupport addOpenGLRunpath; ··· 397 404 # A simple "Hello world" 398 405 import tensorflow as tf 399 406 hello = tf.constant("Hello, world!") 400 - sess = tf.Session() 401 - sess.run(hello) 407 + tf.print(hello) 402 408 403 409 # Fit a simple model to random data 404 410 import numpy as np 405 411 np.random.seed(0) 406 - tf.random.set_random_seed(0) 412 + tf.random.set_seed(0) 407 413 model = tf.keras.models.Sequential([ 408 414 tf.keras.layers.Dense(1, activation="linear") 409 415 ]) ··· 411 419 x = np.random.uniform(size=(1,1)) 412 420 y = np.random.uniform(size=(1,)) 413 421 model.fit(x, y, epochs=1) 414 - 415 - # regression test for #77626 416 - from tensorflow.contrib import tensor_forest 417 422 EOF 418 423 ''; 424 + # Regression test for #77626 removed because not more `tensorflow.contrib`. 419 425 420 426 passthru.libtensorflow = bazel-build.out; 421 427
pkgs/development/python-modules/tensorflow/lift-gast-restriction.patch pkgs/development/python-modules/tensorflow/1/lift-gast-restriction.patch
pkgs/development/python-modules/tensorflow/prefetcher.sh pkgs/development/python-modules/tensorflow/1/prefetcher.sh
+36 -6
pkgs/top-level/python-packages.nix
··· 6548 6548 6549 6549 zerobin = callPackage ../development/python-modules/zerobin { }; 6550 6550 6551 - tensorflow-estimator = callPackage ../development/python-modules/tensorflow-estimator { }; 6552 - tensorflow-estimator_1_15_1 = callPackage ../development/python-modules/tensorflow-estimator/1_15_1.nix { }; 6551 + tensorflow-estimator = self.tensorflow-estimator_1; 6552 + 6553 + tensorflow-estimator_1 = callPackage ../development/python-modules/tensorflow-estimator/1 { }; 6554 + 6555 + tensorflow-estimator_2 = callPackage ../development/python-modules/tensorflow-estimator/2 { }; 6553 6556 6554 6557 tensorflow-probability = callPackage ../development/python-modules/tensorflow-probability { }; 6555 6558 6556 - tensorflow-tensorboard = callPackage ../development/python-modules/tensorflow-tensorboard { }; 6559 + tensorflow-tensorboard = self.tensorflow-tensorboard_1; 6557 6560 6558 - tensorflow-bin = callPackage ../development/python-modules/tensorflow/bin.nix { 6561 + tensorflow-tensorboard_1 = callPackage ../development/python-modules/tensorflow-tensorboard/1 { }; 6562 + 6563 + tensorflow-tensorboard_2 = callPackage ../development/python-modules/tensorflow-tensorboard/2 { }; 6564 + 6565 + tensorflow-bin = self.tensorflow-bin_1; 6566 + 6567 + tensorflow-bin_1 = callPackage ../development/python-modules/tensorflow/1/bin.nix { 6559 6568 cudaSupport = pkgs.config.cudaSupport or false; 6560 6569 inherit (pkgs.linuxPackages) nvidia_x11; 6561 6570 cudatoolkit = pkgs.cudatoolkit_10; 6562 6571 cudnn = pkgs.cudnn_cudatoolkit_10; 6563 6572 }; 6564 6573 6565 - tensorflow-build = callPackage ../development/python-modules/tensorflow { 6574 + tensorflow-bin_2 = callPackage ../development/python-modules/tensorflow/2/bin.nix { 6575 + cudaSupport = pkgs.config.cudaSupport or false; 6576 + inherit (pkgs.linuxPackages) nvidia_x11; 6577 + cudatoolkit = pkgs.cudatoolkit_10; 6578 + cudnn = pkgs.cudnn_cudatoolkit_10; 6579 + }; 6580 + 6581 + tensorflow-build = self.tensorflow-build_1; 6582 + 6583 + tensorflow-build_1 = callPackage ../development/python-modules/tensorflow/1 { 6566 6584 cudaSupport = pkgs.config.cudaSupport or false; 6567 6585 inherit (pkgs.linuxPackages) nvidia_x11; 6568 6586 cudatoolkit = pkgs.cudatoolkit_10; ··· 6590 6572 inherit (pkgs.darwin.apple_sdk.frameworks) Foundation Security; 6591 6573 }; 6592 6574 6593 - tensorflow = self.tensorflow-build; 6575 + tensorflow-build_2 = callPackage ../development/python-modules/tensorflow/2 { 6576 + cudaSupport = pkgs.config.cudaSupport or false; 6577 + inherit (pkgs.linuxPackages) nvidia_x11; 6578 + cudatoolkit = pkgs.cudatoolkit_10; 6579 + cudnn = pkgs.cudnn_cudatoolkit_10; 6580 + nccl = pkgs.nccl_cudatoolkit_10; 6581 + openssl = pkgs.openssl_1_1; 6582 + inherit (pkgs.darwin.apple_sdk.frameworks) Foundation Security; 6583 + }; 6584 + 6585 + tensorflow = self.tensorflow_1; 6586 + tensorflow_1 = self.tensorflow-build_1; 6587 + tensorflow_2 = self.tensorflow-build_2; 6594 6588 6595 6589 tensorflowWithoutCuda = self.tensorflow.override { 6596 6590 cudaSupport = false;