Reduce the size of //tensorflow/tools/pip_package:simple_console_windows
This change reduce the size of //tensorflow/tools/pip_package:simple_console_windows's zip file from 1000027677 bytes to 47690474 bytes for a CPU build. For GPU build, it will avoid going over 4GB when multiple CUDA compatibility are specified. To fix #22390 PiperOrigin-RevId: 214764423
This commit is contained in:
parent
abf2635620
commit
77e2686a29
@ -1440,6 +1440,14 @@ def set_windows_build_flags(environ_cp):
|
||||
# TODO(pcloudy): Remove this flag when upgrading Bazel to 0.16.0
|
||||
# Short object file path will be enabled by default.
|
||||
write_to_bazelrc('build --experimental_shortened_obj_file_path=true')
|
||||
# When building zip file for some py_binary and py_test targets, don't
|
||||
# include its dependencies. This is for:
|
||||
# 1. Running python tests against the system installed TF pip package.
|
||||
# 2. Avoiding redundant files in
|
||||
# //tensorflow/tools/pip_package:simple_console_windows,
|
||||
# which is a py_binary used during creating TF pip package.
|
||||
# See https://github.com/tensorflow/tensorflow/issues/22390
|
||||
write_to_bazelrc('build --define=no_tensorflow_py_deps=true')
|
||||
|
||||
if get_var(
|
||||
environ_cp, 'TF_OVERRIDE_EIGEN_STRONG_INLINE', 'Eigen strong inline',
|
||||
|
@ -3,6 +3,7 @@ licenses(["notice"]) # Apache 2.0
|
||||
package(default_visibility = ["//tensorflow:internal"])
|
||||
|
||||
load("//tensorflow:tensorflow.bzl", "cuda_py_test")
|
||||
load("//tensorflow:tensorflow.bzl", "py_binary")
|
||||
|
||||
py_binary(
|
||||
name = "mnist",
|
||||
|
@ -3,6 +3,7 @@ licenses(["notice"]) # Apache 2.0
|
||||
package(default_visibility = ["//tensorflow:internal"])
|
||||
|
||||
load("//tensorflow:tensorflow.bzl", "cuda_py_test")
|
||||
load("//tensorflow:tensorflow.bzl", "py_binary")
|
||||
|
||||
py_binary(
|
||||
name = "linear_regression",
|
||||
|
@ -3,6 +3,7 @@ licenses(["notice"]) # Apache 2.0
|
||||
package(default_visibility = ["//tensorflow:internal"])
|
||||
|
||||
load("//tensorflow:tensorflow.bzl", "cuda_py_test")
|
||||
load("//tensorflow:tensorflow.bzl", "py_binary")
|
||||
|
||||
py_binary(
|
||||
name = "rnn_colorbot",
|
||||
|
@ -3,6 +3,7 @@ licenses(["notice"]) # Apache 2.0
|
||||
package(default_visibility = ["//tensorflow:internal"])
|
||||
|
||||
load("//tensorflow:tensorflow.bzl", "cuda_py_test")
|
||||
load("//tensorflow:tensorflow.bzl", "py_binary")
|
||||
|
||||
py_binary(
|
||||
name = "rnn_ptb",
|
||||
|
@ -4,6 +4,7 @@ licenses(["notice"]) # Apache 2.0
|
||||
|
||||
load("//tensorflow:tensorflow.bzl", "tf_py_wrap_cc")
|
||||
load("//tensorflow:tensorflow.bzl", "tf_py_test")
|
||||
load("//tensorflow:tensorflow.bzl", "py_binary")
|
||||
|
||||
cc_library(
|
||||
name = "toco_python_api",
|
||||
|
@ -1,4 +1,5 @@
|
||||
load("//tensorflow:tensorflow.bzl", "py_test")
|
||||
load("//tensorflow:tensorflow.bzl", "py_binary")
|
||||
|
||||
package(
|
||||
default_visibility = ["//tensorflow:internal"],
|
||||
|
@ -18,6 +18,7 @@ exports_files(["LICENSE"])
|
||||
|
||||
load("//tensorflow:tensorflow.bzl", "cuda_py_test")
|
||||
load("//tensorflow:tensorflow.bzl", "py_test")
|
||||
load("//tensorflow:tensorflow.bzl", "py_binary")
|
||||
load("//tensorflow:tensorflow.bzl", "if_not_windows")
|
||||
|
||||
py_library(
|
||||
|
@ -8,6 +8,7 @@ licenses(["notice"]) # Apache 2.0
|
||||
exports_files(["LICENSE"])
|
||||
|
||||
load("//tensorflow:tensorflow.bzl", "py_test")
|
||||
load("//tensorflow:tensorflow.bzl", "py_binary")
|
||||
|
||||
# Transitive dependencies of this target will be included in the pip package.
|
||||
py_library(
|
||||
@ -21,6 +22,13 @@ py_library(
|
||||
":saved_model_cli",
|
||||
":saved_model_utils",
|
||||
":strip_unused",
|
||||
# The following py_library are needed because
|
||||
# py_binary may not depend on them when --define=no_tensorflow_py_deps=true
|
||||
# is specified. See https://github.com/tensorflow/tensorflow/issues/22390
|
||||
":freeze_graph_lib",
|
||||
":optimize_for_inference_lib",
|
||||
":selective_registration_header_lib",
|
||||
":strip_unused_lib",
|
||||
],
|
||||
)
|
||||
|
||||
|
@ -1693,6 +1693,29 @@ register_extension_info(
|
||||
label_regex_for_dep = "{extension_name}",
|
||||
)
|
||||
|
||||
# Similar to py_test above, this macro is used to exclude dependencies for some py_binary
|
||||
# targets in order to reduce the size of //tensorflow/tools/pip_package:simple_console_windows.
|
||||
# See https://github.com/tensorflow/tensorflow/issues/22390
|
||||
def py_binary(name, deps = [], **kwargs):
|
||||
# Add an extra target for dependencies to avoid nested select statement.
|
||||
native.py_library(
|
||||
name = name + "_deps",
|
||||
deps = deps,
|
||||
)
|
||||
native.py_binary(
|
||||
name = name,
|
||||
deps = select({
|
||||
"//conditions:default": [":" + name + "_deps"],
|
||||
clean_dep("//tensorflow:no_tensorflow_py_deps"): [],
|
||||
}),
|
||||
**kwargs
|
||||
)
|
||||
|
||||
register_extension_info(
|
||||
extension_name = "py_binary",
|
||||
label_regex_for_dep = "{extension_name}",
|
||||
)
|
||||
|
||||
def tf_py_test(
|
||||
name,
|
||||
srcs,
|
||||
|
@ -8,6 +8,7 @@ licenses(["notice"]) # Apache 2.0
|
||||
exports_files(["LICENSE"])
|
||||
|
||||
load("//tensorflow:tensorflow.bzl", "py_test")
|
||||
load("//tensorflow:tensorflow.bzl", "py_binary")
|
||||
|
||||
py_binary(
|
||||
name = "grpc_tensorflow_server",
|
||||
|
Loading…
Reference in New Issue
Block a user