Switch to mounting the current source in the remote config docker.

Add workaround for the latest toolchain repository not supporting older bazel
versions; only load it conditionally.

PiperOrigin-RevId: 224965872
This commit is contained in:
A. Unique TensorFlower 2018-12-11 02:10:55 -08:00 committed by TensorFlower Gardener
parent f5aed4f8f1
commit 221f4d23c6
6 changed files with 78 additions and 53 deletions

View File

@ -16,30 +16,27 @@ load("@io_bazel_rules_closure//closure:defs.bzl", "closure_repositories")
closure_repositories() closure_repositories()
http_archive( load("//third_party/toolchains/preconfig/generate:archives.bzl",
name = "base_images_docker", "bazel_toolchains_archive")
sha256 = "e2b1b7254270bb7605e814a9dbf6d1e4ae04a11136ff1714fbfdabe3f87f7cf9",
strip_prefix = "base-images-docker-12801524f867e657fbb5d1a74f31618aff181ac6", bazel_toolchains_archive()
urls = ["https://github.com/GoogleCloudPlatform/base-images-docker/archive/12801524f867e657fbb5d1a74f31618aff181ac6.tar.gz"],
load(
"@bazel_toolchains//repositories:repositories.bzl",
bazel_toolchains_repositories = "repositories",
) )
http_archive( bazel_toolchains_repositories()
name = "bazel_toolchains",
sha256 = "15b5858b1b5541ec44df31b94c3b8672815b31d71215a98398761ea9f4c4eedb", load(
strip_prefix = "bazel-toolchains-6200b238c9c2d137c0d9a7262c80cc71d98e692b", "@io_bazel_rules_docker//container:container.bzl",
urls = [ container_repositories = "repositories",
"https://github.com/bazelbuild/bazel-toolchains/archive/6200b238c9c2d137c0d9a7262c80cc71d98e692b.tar.gz",
],
) )
http_archive( container_repositories()
name = "io_bazel_rules_docker",
sha256 = "29d109605e0d6f9c892584f07275b8c9260803bf0c6fcb7de2623b2bedc910bd",
strip_prefix = "rules_docker-0.5.1",
urls = ["https://github.com/bazelbuild/rules_docker/archive/v0.5.1.tar.gz"],
)
load("//third_party/toolchains/preconfig/generate:workspace.bzl", "remote_config_workspace") load("//third_party/toolchains/preconfig/generate:workspace.bzl",
"remote_config_workspace")
remote_config_workspace() remote_config_workspace()

View File

@ -49,6 +49,7 @@ tensorflow/third_party/toolchains/preconfig/ubuntu14.04/nccl2/BUILD
tensorflow/third_party/toolchains/preconfig/generate/workspace.bzl tensorflow/third_party/toolchains/preconfig/generate/workspace.bzl
tensorflow/third_party/toolchains/preconfig/generate/containers.bzl tensorflow/third_party/toolchains/preconfig/generate/containers.bzl
tensorflow/third_party/toolchains/preconfig/generate/generate.bzl tensorflow/third_party/toolchains/preconfig/generate/generate.bzl
tensorflow/third_party/toolchains/preconfig/generate/archives.bzl
tensorflow/third_party/toolchains/preconfig/generate/BUILD tensorflow/third_party/toolchains/preconfig/generate/BUILD
tensorflow/third_party/toolchains/preconfig/win_1803/bazel_018/BUILD tensorflow/third_party/toolchains/preconfig/win_1803/bazel_018/BUILD
tensorflow/third_party/toolchains/preconfig/win_1803/bazel_018/dummy_toolchain.bzl tensorflow/third_party/toolchains/preconfig/win_1803/bazel_018/dummy_toolchain.bzl

View File

@ -1,48 +1,52 @@
""" Helpers to check minimum version of bazel.""" """ Helpers to check minimum version of bazel."""
def _extract_version_number(bazel_version): def _extract_version_number(bazel_version):
"""Extracts the semantic version number from a version string """Extracts the semantic version number from a version string
Args: Args:
bazel_version: the version string that begins with the semantic version bazel_version: the version string that begins with the semantic version
e.g. "1.2.3rc1 abc1234" where "abc1234" is a commit hash. e.g. "1.2.3rc1 abc1234" where "abc1234" is a commit hash.
Returns: Returns:
The semantic version string, like "1.2.3". The semantic version string, like "1.2.3".
""" """
for i in range(len(bazel_version)): for i in range(len(bazel_version)):
c = bazel_version[i] c = bazel_version[i]
if not (c.isdigit() or c == "."): if not (c.isdigit() or c == "."):
return bazel_version[:i] return bazel_version[:i]
return bazel_version return bazel_version
# Parse the bazel version string from `native.bazel_version`. # Parse the bazel version string from `native.bazel_version`.
# e.g. # e.g.
# "0.10.0rc1 abc123d" => (0, 10, 0) # "0.10.0rc1 abc123d" => (0, 10, 0)
# "0.3.0" => (0, 3, 0) # "0.3.0" => (0, 3, 0)
def _parse_bazel_version(bazel_version): def _parse_bazel_version(bazel_version):
"""Parses a version string into a 3-tuple of ints """Parses a version string into a 3-tuple of ints
int tuples can be compared directly using binary operators (<, >). int tuples can be compared directly using binary operators (<, >).
Args: Args:
bazel_version: the Bazel version string bazel_version: the Bazel version string
Returns: Returns:
An int 3-tuple of a (major, minor, patch) version. An int 3-tuple of a (major, minor, patch) version.
""" """
version = _extract_version_number(bazel_version) version = _extract_version_number(bazel_version)
return tuple([int(n) for n in version.split(".")]) return tuple([int(n) for n in version.split(".")])
def check_bazel_version_at_least(minimum_bazel_version): def check_bazel_version_at_least(minimum_bazel_version):
if "bazel_version" not in dir(native): if "bazel_version" not in dir(native):
fail("\nCurrent Bazel version is lower than 0.2.1, expected at least %s\n" % minimum_bazel_version) fail("\nCurrent Bazel version is lower than 0.2.1, expected at least %s\n" % minimum_bazel_version)
elif not native.bazel_version: elif not native.bazel_version:
print("\nCurrent Bazel is not a release version, cannot check for compatibility.") print("\nCurrent Bazel is not a release version, cannot check for compatibility.")
print("Make sure that you are running at least Bazel %s.\n" % minimum_bazel_version) print("Make sure that you are running at least Bazel %s.\n" % minimum_bazel_version)
return return
if _parse_bazel_version(native.bazel_version) < _parse_bazel_version(minimum_bazel_version): if _parse_bazel_version(native.bazel_version) < _parse_bazel_version(minimum_bazel_version):
fail("\nCurrent Bazel version is {}, expected at least {}\n".format( fail("\nCurrent Bazel version is {}, expected at least {}\n".format(
native.bazel_version, minimum_bazel_version)) native.bazel_version,
minimum_bazel_version,
))
parse_bazel_version = _parse_bazel_version

View File

@ -0,0 +1,25 @@
load("//tensorflow:version_check.bzl", "parse_bazel_version")
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
def bazel_toolchains_archive():
if parse_bazel_version(native.bazel_version) >= parse_bazel_version("0.19"):
# This version of the toolchains repo is incompatible with older bazel
# versions - we can remove this once TensorFlow drops support for bazel
# before 0.19.
http_archive(
name = "bazel_toolchains",
sha256 = "41c48a189be489e2d15dec40e0057ea15b95ee5b39cc2a7e6cf663e31432c75e",
strip_prefix = "bazel-toolchains-3f8c58fe530fedc446de04673bc1e32985887dea",
urls = [
"https://github.com/nlopezgi/bazel-toolchains/archive/3f8c58fe530fedc446de04673bc1e32985887dea.tar.gz",
],
)
else:
http_archive(
name = "bazel_toolchains",
sha256 = "15b5858b1b5541ec44df31b94c3b8672815b31d71215a98398761ea9f4c4eedb",
strip_prefix = "bazel-toolchains-6200b238c9c2d137c0d9a7262c80cc71d98e692b",
urls = [
"https://github.com/bazelbuild/bazel-toolchains/archive/6200b238c9c2d137c0d9a7262c80cc71d98e692b.tar.gz",
],
)

View File

@ -36,9 +36,7 @@ def _tensorflow_rbe_config(name, cuda_version, cudnn_version, python_version, co
"TF_NCCL_VERSION": "2", "TF_NCCL_VERSION": "2",
"CUDNN_INSTALL_PATH": "/usr/lib/x86_64-linux-gnu", "CUDNN_INSTALL_PATH": "/usr/lib/x86_64-linux-gnu",
}, },
# TODO(klimek): We should use the sources that we currently work on, not mount_project = "$(mount_project)",
# just the latest snapshot of tensorflow that is checked in.
git_repo = "https://github.com/tensorflow/tensorflow",
tags = ["manual"], tags = ["manual"],
incompatible_changes_off = True, incompatible_changes_off = True,
) )

View File

@ -46,7 +46,7 @@ echo "CUDA: ${CUDA_VERSION}"
echo "CUDNN: ${CUDNN_VERSION}" echo "CUDNN: ${CUDNN_VERSION}"
echo "NCCL: ${NCCL_VERSION}" echo "NCCL: ${NCCL_VERSION}"
bazel build "${PKG}/generate:${TARGET}" bazel build --define=mount_project="${PWD}" "${PKG}/generate:${TARGET}"
cd "${TEMPDIR}" cd "${TEMPDIR}"
tar xvf "${ROOT}/bazel-bin/${PKG}/generate/${TARGET}_outputs.tar" tar xvf "${ROOT}/bazel-bin/${PKG}/generate/${TARGET}_outputs.tar"