Breaks the build. Rollback.
PiperOrigin-RevId: 321610483 Change-Id: I0bba8a5d626275be22029da4abb6cb3ac18f03f5
This commit is contained in:
parent
bd3b7979d2
commit
5a244072f2
@ -101,6 +101,7 @@ tensorflow/third_party/gpus/cuda/cuda_config.h.tpl
|
||||
tensorflow/third_party/gpus/cuda/cuda_config.py.tpl
|
||||
tensorflow/third_party/gpus/cuda_configure.bzl
|
||||
tensorflow/third_party/gpus/find_cuda_config.py
|
||||
tensorflow/third_party/gpus/find_cuda_config.py.gz.base64
|
||||
tensorflow/third_party/gpus/rocm/BUILD
|
||||
tensorflow/third_party/gpus/rocm/BUILD.tpl
|
||||
tensorflow/third_party/gpus/rocm/build_defs.bzl.tpl
|
||||
|
37
third_party/gpus/compress_find_cuda_config.py
vendored
Normal file
37
third_party/gpus/compress_find_cuda_config.py
vendored
Normal file
@ -0,0 +1,37 @@
|
||||
# Copyright 2020 The TensorFlow Authors. All Rights Reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
# ==============================================================================
|
||||
"""Compresses the contents of 'find_cuda.py'.
|
||||
|
||||
The compressed file is what is actually being used. It works around remote
|
||||
config not being able to upload files yet.
|
||||
"""
|
||||
import base64
|
||||
import zlib
|
||||
|
||||
|
||||
def main():
|
||||
with open('find_cuda.py', 'rb') as f:
|
||||
data = f.read()
|
||||
|
||||
compressed = zlib.compress(data)
|
||||
b64encoded = base64.b64encode(compressed)
|
||||
|
||||
with open('find_cuda.py.gz.base64', 'wb') as f:
|
||||
f.write(b64encoded)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
44
third_party/gpus/cuda_configure.bzl
vendored
44
third_party/gpus/cuda_configure.bzl
vendored
@ -605,19 +605,42 @@ def _cudart_static_linkopt(cpu_value):
|
||||
"""Returns additional platform-specific linkopts for cudart."""
|
||||
return "" if cpu_value == "Darwin" else "\"-lrt\","
|
||||
|
||||
def _exec_find_cuda_config(repository_ctx, script_path, cuda_libraries):
|
||||
python_bin = get_python_bin(repository_ctx)
|
||||
|
||||
# If used with remote execution then repository_ctx.execute() can't
|
||||
# access files from the source tree. A trick is to read the contents
|
||||
# of the file in Starlark and embed them as part of the command. In
|
||||
# this case the trick is not sufficient as the find_cuda_config.py
|
||||
# script has more than 8192 characters. 8192 is the command length
|
||||
# limit of cmd.exe on Windows. Thus we additionally need to compress
|
||||
# the contents locally and decompress them as part of the execute().
|
||||
compressed_contents = repository_ctx.read(script_path)
|
||||
decompress_and_execute_cmd = (
|
||||
"from zlib import decompress;" +
|
||||
"from base64 import b64decode;" +
|
||||
"from os import system;" +
|
||||
"script = decompress(b64decode('%s'));" % compressed_contents +
|
||||
"f = open('script.py', 'wb');" +
|
||||
"f.write(script);" +
|
||||
"f.close();" +
|
||||
"system('\"%s\" script.py %s');" % (python_bin, " ".join(cuda_libraries))
|
||||
)
|
||||
|
||||
return execute(repository_ctx, [python_bin, "-c", decompress_and_execute_cmd])
|
||||
|
||||
# TODO(csigg): Only call once instead of from here, tensorrt_configure.bzl,
|
||||
# and nccl_configure.bzl.
|
||||
def find_cuda_config(repository_ctx, cuda_libraries):
|
||||
def find_cuda_config(repository_ctx, script_path, cuda_libraries):
|
||||
"""Returns CUDA config dictionary from running find_cuda_config.py"""
|
||||
python_bin = get_python_bin(repository_ctx)
|
||||
exec_result = execute(repository_ctx, [python_bin, repository_ctx.attr._find_cuda_config] + cuda_libraries)
|
||||
exec_result = _exec_find_cuda_config(repository_ctx, script_path, cuda_libraries)
|
||||
if exec_result.return_code:
|
||||
auto_configure_fail("Failed to run find_cuda_config.py: %s" % err_out(exec_result))
|
||||
|
||||
# Parse the dict from stdout.
|
||||
return dict([tuple(x.split(": ")) for x in exec_result.stdout.splitlines()])
|
||||
|
||||
def _get_cuda_config(repository_ctx):
|
||||
def _get_cuda_config(repository_ctx, find_cuda_config_script):
|
||||
"""Detects and returns information about the CUDA installation on the system.
|
||||
|
||||
Args:
|
||||
@ -632,7 +655,7 @@ def _get_cuda_config(repository_ctx):
|
||||
compute_capabilities: A list of the system's CUDA compute capabilities.
|
||||
cpu_value: The name of the host operating system.
|
||||
"""
|
||||
config = find_cuda_config(repository_ctx, ["cuda", "cudnn"])
|
||||
config = find_cuda_config(repository_ctx, find_cuda_config_script, ["cuda", "cudnn"])
|
||||
cpu_value = get_cpu_value(repository_ctx)
|
||||
toolkit_path = config["cuda_toolkit_path"]
|
||||
|
||||
@ -928,8 +951,9 @@ def _create_local_cuda_repository(repository_ctx):
|
||||
"cuda:cuda_config.py",
|
||||
]}
|
||||
tpl_paths["cuda:BUILD"] = _tpl_path(repository_ctx, "cuda:BUILD.windows" if is_windows(repository_ctx) else "cuda:BUILD")
|
||||
find_cuda_config_script = repository_ctx.path(Label("@org_tensorflow//third_party/gpus:find_cuda_config.py.gz.base64"))
|
||||
|
||||
cuda_config = _get_cuda_config(repository_ctx)
|
||||
cuda_config = _get_cuda_config(repository_ctx, find_cuda_config_script)
|
||||
|
||||
cuda_include_path = cuda_config.config["cuda_include_dir"]
|
||||
cublas_include_path = cuda_config.config["cublas_include_dir"]
|
||||
@ -1370,20 +1394,12 @@ remote_cuda_configure = repository_rule(
|
||||
remotable = True,
|
||||
attrs = {
|
||||
"environ": attr.string_dict(),
|
||||
"_find_cuda_config": attr.label(
|
||||
default = Label("@org_tensorflow//third_party/gpus:find_cuda_config.py"),
|
||||
),
|
||||
},
|
||||
)
|
||||
|
||||
cuda_configure = repository_rule(
|
||||
implementation = _cuda_autoconf_impl,
|
||||
environ = _ENVIRONS + [_TF_CUDA_CONFIG_REPO],
|
||||
attrs = {
|
||||
"_find_cuda_config": attr.label(
|
||||
default = Label("@org_tensorflow//third_party/gpus:find_cuda_config.py"),
|
||||
),
|
||||
},
|
||||
)
|
||||
"""Detects and configures the local CUDA toolchain.
|
||||
|
||||
|
1
third_party/gpus/find_cuda_config.py.gz.base64
vendored
Normal file
1
third_party/gpus/find_cuda_config.py.gz.base64
vendored
Normal file
File diff suppressed because one or more lines are too long
18
third_party/nccl/nccl_configure.bzl
vendored
18
third_party/nccl/nccl_configure.bzl
vendored
@ -64,11 +64,17 @@ def _label(file):
|
||||
return Label("//third_party/nccl:{}".format(file))
|
||||
|
||||
def _create_local_nccl_repository(repository_ctx):
|
||||
# Resolve all labels before doing any real work. Resolving causes the
|
||||
# function to be restarted with all previous state being lost. This
|
||||
# can easily lead to a O(n^2) runtime in the number of labels.
|
||||
# See https://github.com/tensorflow/tensorflow/commit/62bd3534525a036f07d9851b3199d68212904778
|
||||
find_cuda_config_path = repository_ctx.path(Label("@org_tensorflow//third_party/gpus:find_cuda_config.py.gz.base64"))
|
||||
|
||||
nccl_version = get_host_environ(repository_ctx, _TF_NCCL_VERSION, "")
|
||||
if nccl_version:
|
||||
nccl_version = nccl_version.split(".")[0]
|
||||
|
||||
cuda_config = find_cuda_config(repository_ctx, ["cuda"])
|
||||
cuda_config = find_cuda_config(repository_ctx, find_cuda_config_path, ["cuda"])
|
||||
cuda_version = cuda_config["cuda_version"].split(".")
|
||||
cuda_major = cuda_version[0]
|
||||
cuda_minor = cuda_version[1]
|
||||
@ -90,7 +96,7 @@ def _create_local_nccl_repository(repository_ctx):
|
||||
)
|
||||
else:
|
||||
# Create target for locally installed NCCL.
|
||||
config = find_cuda_config(repository_ctx, ["nccl"])
|
||||
config = find_cuda_config(repository_ctx, find_cuda_config_path, ["nccl"])
|
||||
config_wrap = {
|
||||
"%{nccl_version}": config["nccl_version"],
|
||||
"%{nccl_header_dir}": config["nccl_include_dir"],
|
||||
@ -139,20 +145,12 @@ remote_nccl_configure = repository_rule(
|
||||
remotable = True,
|
||||
attrs = {
|
||||
"environ": attr.string_dict(),
|
||||
"_find_cuda_config": attr.label(
|
||||
default = Label("@org_tensorflow//third_party/gpus:find_cuda_config.py"),
|
||||
),
|
||||
},
|
||||
)
|
||||
|
||||
nccl_configure = repository_rule(
|
||||
implementation = _nccl_autoconf_impl,
|
||||
environ = _ENVIRONS,
|
||||
attrs = {
|
||||
"_find_cuda_config": attr.label(
|
||||
default = Label("@org_tensorflow//third_party/gpus:find_cuda_config.py"),
|
||||
),
|
||||
},
|
||||
)
|
||||
"""Detects and configures the NCCL configuration.
|
||||
|
||||
|
7
third_party/tensorrt/tensorrt_configure.bzl
vendored
7
third_party/tensorrt/tensorrt_configure.bzl
vendored
@ -88,13 +88,14 @@ def _create_local_tensorrt_repository(repository_ctx):
|
||||
# function to be restarted with all previous state being lost. This
|
||||
# can easily lead to a O(n^2) runtime in the number of labels.
|
||||
# See https://github.com/tensorflow/tensorflow/commit/62bd3534525a036f07d9851b3199d68212904778
|
||||
find_cuda_config_path = repository_ctx.path(Label("@org_tensorflow//third_party/gpus:find_cuda_config.py.gz.base64"))
|
||||
tpl_paths = {
|
||||
"build_defs.bzl": _tpl_path(repository_ctx, "build_defs.bzl"),
|
||||
"BUILD": _tpl_path(repository_ctx, "BUILD"),
|
||||
"tensorrt/include/tensorrt_config.h": _tpl_path(repository_ctx, "tensorrt/include/tensorrt_config.h"),
|
||||
}
|
||||
|
||||
config = find_cuda_config(repository_ctx, ["tensorrt"])
|
||||
config = find_cuda_config(repository_ctx, find_cuda_config_path, ["tensorrt"])
|
||||
trt_version = config["tensorrt_version"]
|
||||
cpu_value = get_cpu_value(repository_ctx)
|
||||
|
||||
@ -190,16 +191,12 @@ remote_tensorrt_configure = repository_rule(
|
||||
remotable = True,
|
||||
attrs = {
|
||||
"environ": attr.string_dict(),
|
||||
"_find_cuda_config": attr.label(default = "@org_tensorflow//third_party/gpus:find_cuda_config.py"),
|
||||
},
|
||||
)
|
||||
|
||||
tensorrt_configure = repository_rule(
|
||||
implementation = _tensorrt_configure_impl,
|
||||
environ = _ENVIRONS + [_TF_TENSORRT_CONFIG_REPO],
|
||||
attrs = {
|
||||
"_find_cuda_config": attr.label(default = "@org_tensorflow//third_party/gpus:find_cuda_config.py"),
|
||||
},
|
||||
)
|
||||
"""Detects and configures the local CUDA toolchain.
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user