Add generated RBE config for CUDA 10.1.
PiperOrigin-RevId: 278828693 Change-Id: Ic559929c616e44d10f9ca88beb320e83ccf97a83
This commit is contained in:
parent
7d2f2375a2
commit
4f11eb8e53
@ -241,10 +241,14 @@ tensorflow/third_party/toolchains/preconfig/ubuntu16.04/clang_manylinux2010-cuda
|
||||
tensorflow/third_party/toolchains/preconfig/ubuntu16.04/clang_manylinux2010-cuda10.0/cc_toolchain_config.bzl
|
||||
tensorflow/third_party/toolchains/preconfig/ubuntu16.04/cuda10.0-cudnn7/cuda/BUILD
|
||||
tensorflow/third_party/toolchains/preconfig/ubuntu16.04/cuda10.0-cudnn7/cuda/build_defs.bzl
|
||||
tensorflow/third_party/toolchains/preconfig/ubuntu16.04/cuda10.1-cudnn7/cuda/BUILD
|
||||
tensorflow/third_party/toolchains/preconfig/ubuntu16.04/cuda10.1-cudnn7/cuda/build_defs.bzl
|
||||
tensorflow/third_party/toolchains/preconfig/ubuntu16.04/gcc5-rocm/BUILD
|
||||
tensorflow/third_party/toolchains/preconfig/ubuntu16.04/gcc5-rocm/cc_toolchain_config.bzl
|
||||
tensorflow/third_party/toolchains/preconfig/ubuntu16.04/gcc7_manylinux2010-nvcc-cuda10.0/BUILD
|
||||
tensorflow/third_party/toolchains/preconfig/ubuntu16.04/gcc7_manylinux2010-nvcc-cuda10.0/cc_toolchain_config.bzl
|
||||
tensorflow/third_party/toolchains/preconfig/ubuntu16.04/gcc7_manylinux2010-nvcc-cuda10.1/BUILD
|
||||
tensorflow/third_party/toolchains/preconfig/ubuntu16.04/gcc7_manylinux2010-nvcc-cuda10.1/cc_toolchain_config.bzl
|
||||
tensorflow/third_party/toolchains/preconfig/ubuntu16.04/gcc7_manylinux2010/BUILD
|
||||
tensorflow/third_party/toolchains/preconfig/ubuntu16.04/gcc7_manylinux2010/cc_toolchain_config.bzl
|
||||
tensorflow/third_party/toolchains/preconfig/ubuntu16.04/gcc7_manylinux2010/dummy_toolchain.bzl
|
||||
@ -256,6 +260,8 @@ tensorflow/third_party/toolchains/preconfig/ubuntu16.04/rocm/rocm/build_defs.bzl
|
||||
tensorflow/third_party/toolchains/preconfig/ubuntu16.04/tensorrt5.1/BUILD
|
||||
tensorflow/third_party/toolchains/preconfig/ubuntu16.04/tensorrt5.1/build_defs.bzl
|
||||
tensorflow/third_party/toolchains/preconfig/ubuntu16.04/tensorrt5/BUILD
|
||||
tensorflow/third_party/toolchains/preconfig/ubuntu16.04/tensorrt6.0/BUILD
|
||||
tensorflow/third_party/toolchains/preconfig/ubuntu16.04/tensorrt6.0/build_defs.bzl
|
||||
tensorflow/third_party/toolchains/preconfig/win_1803/BUILD
|
||||
tensorflow/third_party/toolchains/preconfig/win_1803/bazel_025/BUILD
|
||||
tensorflow/third_party/toolchains/preconfig/win_1803/bazel_026/BUILD
|
||||
|
2
third_party/toolchains/preconfig/ubuntu16.04/cuda10.1-cudnn7/WORKSPACE
vendored
Normal file
2
third_party/toolchains/preconfig/ubuntu16.04/cuda10.1-cudnn7/WORKSPACE
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
# DO NOT EDIT: automatically generated WORKSPACE file for cuda_configure rule
|
||||
workspace(name = "local_config_cuda")
|
1346
third_party/toolchains/preconfig/ubuntu16.04/cuda10.1-cudnn7/cuda/BUILD
vendored
Executable file
1346
third_party/toolchains/preconfig/ubuntu16.04/cuda10.1-cudnn7/cuda/BUILD
vendored
Executable file
File diff suppressed because it is too large
Load Diff
72
third_party/toolchains/preconfig/ubuntu16.04/cuda10.1-cudnn7/cuda/build_defs.bzl
vendored
Executable file
72
third_party/toolchains/preconfig/ubuntu16.04/cuda10.1-cudnn7/cuda/build_defs.bzl
vendored
Executable file
@ -0,0 +1,72 @@
|
||||
# Macros for building CUDA code.
|
||||
def if_cuda(if_true, if_false = []):
|
||||
"""Shorthand for select()'ing on whether we're building with CUDA.
|
||||
|
||||
Returns a select statement which evaluates to if_true if we're building
|
||||
with CUDA enabled. Otherwise, the select statement evaluates to if_false.
|
||||
|
||||
"""
|
||||
return select({
|
||||
"@local_config_cuda//cuda:using_nvcc": if_true,
|
||||
"@local_config_cuda//cuda:using_clang": if_true,
|
||||
"//conditions:default": if_false,
|
||||
})
|
||||
|
||||
def if_cuda_clang(if_true, if_false = []):
|
||||
"""Shorthand for select()'ing on wheteher we're building with cuda-clang.
|
||||
|
||||
Returns a select statement which evaluates to if_true if we're building
|
||||
with cuda-clang. Otherwise, the select statement evaluates to if_false.
|
||||
|
||||
"""
|
||||
return select({
|
||||
"@local_config_cuda//cuda:using_clang": if_true,
|
||||
"//conditions:default": if_false,
|
||||
})
|
||||
|
||||
def cuda_default_copts():
|
||||
"""Default options for all CUDA compilations."""
|
||||
return if_cuda(["-x", "cuda", "-DGOOGLE_CUDA=1"]) + if_cuda_clang(["--cuda-gpu-arch=sm_30", "--cuda-gpu-arch=sm_60"])
|
||||
|
||||
def cuda_is_configured():
|
||||
"""Returns true if CUDA was enabled during the configure process."""
|
||||
return True
|
||||
|
||||
def if_cuda_is_configured(x):
|
||||
"""Tests if the CUDA was enabled during the configure process.
|
||||
|
||||
Unlike if_cuda(), this does not require that we are building with
|
||||
--config=cuda. Used to allow non-CUDA code to depend on CUDA libraries.
|
||||
"""
|
||||
if cuda_is_configured():
|
||||
return select({"//conditions:default": x})
|
||||
return select({"//conditions:default": []})
|
||||
|
||||
def cuda_header_library(
|
||||
name,
|
||||
hdrs,
|
||||
include_prefix = None,
|
||||
strip_include_prefix = None,
|
||||
deps = [],
|
||||
**kwargs):
|
||||
"""Generates a cc_library containing both virtual and system include paths.
|
||||
|
||||
Generates both a header-only target with virtual includes plus the full
|
||||
target without virtual includes. This works around the fact that bazel can't
|
||||
mix 'includes' and 'include_prefix' in the same target."""
|
||||
|
||||
native.cc_library(
|
||||
name = name + "_virtual",
|
||||
hdrs = hdrs,
|
||||
include_prefix = include_prefix,
|
||||
strip_include_prefix = strip_include_prefix,
|
||||
deps = deps,
|
||||
visibility = ["//visibility:private"],
|
||||
)
|
||||
|
||||
native.cc_library(
|
||||
name = name,
|
||||
textual_hdrs = hdrs,
|
||||
deps = deps + [":%s_virtual" % name],
|
||||
**kwargs
|
||||
)
|
27
third_party/toolchains/preconfig/ubuntu16.04/cuda10.1-cudnn7/cuda/cuda/cuda_config.h
vendored
Executable file
27
third_party/toolchains/preconfig/ubuntu16.04/cuda10.1-cudnn7/cuda/cuda/cuda_config.h
vendored
Executable file
@ -0,0 +1,27 @@
|
||||
/* Copyright 2015 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.
|
||||
==============================================================================*/
|
||||
|
||||
#ifndef CUDA_CUDA_CONFIG_H_
|
||||
#define CUDA_CUDA_CONFIG_H_
|
||||
|
||||
#define TF_CUDA_CAPABILITIES CudaVersion("3.0"), CudaVersion("6.0")
|
||||
|
||||
#define TF_CUDA_VERSION "10.1"
|
||||
#define TF_CUDA_LIB_VERSION "10"
|
||||
#define TF_CUDNN_VERSION "7"
|
||||
|
||||
#define TF_CUDA_TOOLKIT_PATH "/usr/local/cuda-10.1"
|
||||
|
||||
#endif // CUDA_CUDA_CONFIG_H_
|
169
third_party/toolchains/preconfig/ubuntu16.04/gcc7_manylinux2010-nvcc-cuda10.1/BUILD
vendored
Executable file
169
third_party/toolchains/preconfig/ubuntu16.04/gcc7_manylinux2010-nvcc-cuda10.1/BUILD
vendored
Executable file
@ -0,0 +1,169 @@
|
||||
# This file is expanded from a template by cuda_configure.bzl
|
||||
# Update cuda_configure.bzl#verify_build_defines when adding new variables.
|
||||
|
||||
load(":cc_toolchain_config.bzl", "cc_toolchain_config")
|
||||
|
||||
licenses(["restricted"])
|
||||
|
||||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
toolchain(
|
||||
name = "toolchain-linux-x86_64",
|
||||
exec_compatible_with = [
|
||||
"@bazel_tools//platforms:linux",
|
||||
"@bazel_tools//platforms:x86_64",
|
||||
],
|
||||
target_compatible_with = [
|
||||
"@bazel_tools//platforms:linux",
|
||||
"@bazel_tools//platforms:x86_64",
|
||||
],
|
||||
toolchain = ":cc-compiler-local",
|
||||
toolchain_type = "@bazel_tools//tools/cpp:toolchain_type",
|
||||
)
|
||||
|
||||
cc_toolchain_suite(
|
||||
name = "toolchain",
|
||||
toolchains = {
|
||||
"local|compiler": ":cc-compiler-local",
|
||||
"darwin|compiler": ":cc-compiler-darwin",
|
||||
"x64_windows|msvc-cl": ":cc-compiler-windows",
|
||||
"x64_windows": ":cc-compiler-windows",
|
||||
"arm": ":cc-compiler-local",
|
||||
"aarch64": ":cc-compiler-local",
|
||||
"k8": ":cc-compiler-local",
|
||||
"piii": ":cc-compiler-local",
|
||||
"ppc": ":cc-compiler-local",
|
||||
"darwin": ":cc-compiler-darwin",
|
||||
},
|
||||
)
|
||||
|
||||
cc_toolchain(
|
||||
name = "cc-compiler-local",
|
||||
all_files = ":crosstool_wrapper_driver_is_not_gcc",
|
||||
compiler_files = ":empty",
|
||||
dwp_files = ":empty",
|
||||
linker_files = ":crosstool_wrapper_driver_is_not_gcc",
|
||||
objcopy_files = ":empty",
|
||||
strip_files = ":empty",
|
||||
# To support linker flags that need to go to the start of command line
|
||||
# we need the toolchain to support parameter files. Parameter files are
|
||||
# last on the command line and contain all shared libraries to link, so all
|
||||
# regular options will be left of them.
|
||||
supports_param_files = 1,
|
||||
toolchain_config = ":cc-compiler-local-config",
|
||||
toolchain_identifier = "local_linux",
|
||||
)
|
||||
|
||||
cc_toolchain_config(
|
||||
name = "cc-compiler-local-config",
|
||||
builtin_include_directories = [
|
||||
"/dt7/usr/include/c++/7",
|
||||
"/dt7/usr/include/c++/7/x86_64-pc-linux-gnu",
|
||||
"/dt7/usr/include/c++/7/backward",
|
||||
"/dt7/usr/lib/gcc/x86_64-pc-linux-gnu/7/include",
|
||||
"/dt7/usr/lib/gcc/x86_64-pc-linux-gnu/7/include-fixed",
|
||||
"/dt7/usr/include",
|
||||
"/usr/local/cuda-10.1/targets/x86_64-linux/include",
|
||||
"/usr/local/cuda-10.1/include",
|
||||
"/usr/local/cuda-10.1/extras/CUPTI/include",
|
||||
"/usr/include",
|
||||
],
|
||||
builtin_sysroot = "",
|
||||
cpu = "local",
|
||||
cuda_path = "",
|
||||
extra_no_canonical_prefixes_flags = ["-fno-canonical-system-headers"],
|
||||
host_compiler_path = "clang/bin/crosstool_wrapper_driver_is_not_gcc",
|
||||
host_compiler_prefix = "/usr/bin",
|
||||
host_compiler_warnings = [],
|
||||
host_unfiltered_compile_flags = [],
|
||||
linker_bin_path = "/usr/bin",
|
||||
)
|
||||
|
||||
cc_toolchain(
|
||||
name = "cc-compiler-darwin",
|
||||
all_files = ":crosstool_wrapper_driver_is_not_gcc",
|
||||
compiler_files = ":empty",
|
||||
dwp_files = ":empty",
|
||||
linker_files = ":crosstool_wrapper_driver_is_not_gcc",
|
||||
objcopy_files = ":empty",
|
||||
strip_files = ":empty",
|
||||
supports_param_files = 0,
|
||||
toolchain_config = ":cc-compiler-local-darwin",
|
||||
toolchain_identifier = "local_darwin",
|
||||
)
|
||||
|
||||
cc_toolchain_config(
|
||||
name = "cc-compiler-local-darwin",
|
||||
builtin_include_directories = [
|
||||
"/dt7/usr/include/c++/7",
|
||||
"/dt7/usr/include/c++/7/x86_64-pc-linux-gnu",
|
||||
"/dt7/usr/include/c++/7/backward",
|
||||
"/dt7/usr/lib/gcc/x86_64-pc-linux-gnu/7/include",
|
||||
"/dt7/usr/lib/gcc/x86_64-pc-linux-gnu/7/include-fixed",
|
||||
"/dt7/usr/include",
|
||||
"/usr/local/cuda-10.1/targets/x86_64-linux/include",
|
||||
"/usr/local/cuda-10.1/include",
|
||||
"/usr/local/cuda-10.1/extras/CUPTI/include",
|
||||
"/usr/include",
|
||||
],
|
||||
cpu = "darwin",
|
||||
extra_no_canonical_prefixes_flags = ["-fno-canonical-system-headers"],
|
||||
host_compiler_path = "clang/bin/crosstool_wrapper_driver_is_not_gcc",
|
||||
host_compiler_prefix = "/usr/bin",
|
||||
host_compiler_warnings = [],
|
||||
host_unfiltered_compile_flags = [],
|
||||
linker_bin_path = "/usr/bin",
|
||||
)
|
||||
|
||||
cc_toolchain(
|
||||
name = "cc-compiler-windows",
|
||||
all_files = ":windows_msvc_wrapper_files",
|
||||
compiler_files = ":empty",
|
||||
dwp_files = ":empty",
|
||||
linker_files = ":windows_msvc_wrapper_files",
|
||||
objcopy_files = ":empty",
|
||||
strip_files = ":empty",
|
||||
supports_param_files = 1,
|
||||
toolchain_config = ":cc-compiler-windows-config",
|
||||
toolchain_identifier = "local_windows",
|
||||
)
|
||||
|
||||
cc_toolchain_config(
|
||||
name = "cc-compiler-windows-config",
|
||||
builtin_include_directories = [
|
||||
"/dt7/usr/include/c++/7",
|
||||
"/dt7/usr/include/c++/7/x86_64-pc-linux-gnu",
|
||||
"/dt7/usr/include/c++/7/backward",
|
||||
"/dt7/usr/lib/gcc/x86_64-pc-linux-gnu/7/include",
|
||||
"/dt7/usr/lib/gcc/x86_64-pc-linux-gnu/7/include-fixed",
|
||||
"/dt7/usr/include",
|
||||
"/usr/local/cuda-10.1/targets/x86_64-linux/include",
|
||||
"/usr/local/cuda-10.1/include",
|
||||
"/usr/local/cuda-10.1/extras/CUPTI/include",
|
||||
"/usr/include",
|
||||
],
|
||||
cpu = "x64_windows",
|
||||
msvc_cl_path = "msvc_not_used",
|
||||
msvc_env_include = "msvc_not_used",
|
||||
msvc_env_lib = "msvc_not_used",
|
||||
msvc_env_path = "msvc_not_used",
|
||||
msvc_env_tmp = "msvc_not_used",
|
||||
msvc_lib_path = "msvc_not_used",
|
||||
msvc_link_path = "msvc_not_used",
|
||||
msvc_ml_path = "msvc_not_used",
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "empty",
|
||||
srcs = [],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "crosstool_wrapper_driver_is_not_gcc",
|
||||
srcs = ["clang/bin/crosstool_wrapper_driver_is_not_gcc"],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "windows_msvc_wrapper_files",
|
||||
srcs = glob(["windows/msvc_*"]),
|
||||
)
|
1516
third_party/toolchains/preconfig/ubuntu16.04/gcc7_manylinux2010-nvcc-cuda10.1/cc_toolchain_config.bzl
vendored
Executable file
1516
third_party/toolchains/preconfig/ubuntu16.04/gcc7_manylinux2010-nvcc-cuda10.1/cc_toolchain_config.bzl
vendored
Executable file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,267 @@
|
||||
#!/usr/bin/env python
|
||||
# Copyright 2015 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.
|
||||
# ==============================================================================
|
||||
|
||||
"""Crosstool wrapper for compiling CUDA programs.
|
||||
|
||||
SYNOPSIS:
|
||||
crosstool_wrapper_is_not_gcc [options passed in by cc_library()
|
||||
or cc_binary() rule]
|
||||
|
||||
DESCRIPTION:
|
||||
This script is expected to be called by the cc_library() or cc_binary() bazel
|
||||
rules. When the option "-x cuda" is present in the list of arguments passed
|
||||
to this script, it invokes the nvcc CUDA compiler. Most arguments are passed
|
||||
as is as a string to --compiler-options of nvcc. When "-x cuda" is not
|
||||
present, this wrapper invokes hybrid_driver_is_not_gcc with the input
|
||||
arguments as is.
|
||||
|
||||
NOTES:
|
||||
Changes to the contents of this file must be propagated from
|
||||
//third_party/gpus/crosstool/crosstool_wrapper_is_not_gcc to
|
||||
//third_party/gpus/crosstool/v*/*/clang/bin/crosstool_wrapper_is_not_gcc
|
||||
"""
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
__author__ = 'keveman@google.com (Manjunath Kudlur)'
|
||||
|
||||
from argparse import ArgumentParser
|
||||
import os
|
||||
import subprocess
|
||||
import re
|
||||
import sys
|
||||
import pipes
|
||||
|
||||
# Template values set by cuda_autoconf.
|
||||
CPU_COMPILER = ('/dt7/usr/bin/gcc')
|
||||
GCC_HOST_COMPILER_PATH = ('/dt7/usr/bin/gcc')
|
||||
|
||||
NVCC_PATH = '/usr/local/cuda-10.1/bin/nvcc'
|
||||
PREFIX_DIR = os.path.dirname(GCC_HOST_COMPILER_PATH)
|
||||
NVCC_VERSION = '10.1'
|
||||
|
||||
def Log(s):
|
||||
print('gpus/crosstool: {0}'.format(s))
|
||||
|
||||
|
||||
def GetOptionValue(argv, option):
|
||||
"""Extract the list of values for option from the argv list.
|
||||
|
||||
Args:
|
||||
argv: A list of strings, possibly the argv passed to main().
|
||||
option: The option whose value to extract, without the leading '-'.
|
||||
|
||||
Returns:
|
||||
A list of values, either directly following the option,
|
||||
(eg., -opt val1 val2) or values collected from multiple occurrences of
|
||||
the option (eg., -opt val1 -opt val2).
|
||||
"""
|
||||
|
||||
parser = ArgumentParser()
|
||||
parser.add_argument('-' + option, nargs='*', action='append')
|
||||
args, _ = parser.parse_known_args(argv)
|
||||
if not args or not vars(args)[option]:
|
||||
return []
|
||||
else:
|
||||
return sum(vars(args)[option], [])
|
||||
|
||||
|
||||
def GetHostCompilerOptions(argv):
|
||||
"""Collect the -isystem, -iquote, and --sysroot option values from argv.
|
||||
|
||||
Args:
|
||||
argv: A list of strings, possibly the argv passed to main().
|
||||
|
||||
Returns:
|
||||
The string that can be used as the --compiler-options to nvcc.
|
||||
"""
|
||||
|
||||
parser = ArgumentParser()
|
||||
parser.add_argument('-isystem', nargs='*', action='append')
|
||||
parser.add_argument('-iquote', nargs='*', action='append')
|
||||
parser.add_argument('--sysroot', nargs=1)
|
||||
parser.add_argument('-g', nargs='*', action='append')
|
||||
parser.add_argument('-fno-canonical-system-headers', action='store_true')
|
||||
parser.add_argument('-no-canonical-prefixes', action='store_true')
|
||||
|
||||
args, _ = parser.parse_known_args(argv)
|
||||
|
||||
opts = ''
|
||||
|
||||
if args.isystem:
|
||||
opts += ' -isystem ' + ' -isystem '.join(sum(args.isystem, []))
|
||||
if args.iquote:
|
||||
opts += ' -iquote ' + ' -iquote '.join(sum(args.iquote, []))
|
||||
if args.g:
|
||||
opts += ' -g' + ' -g'.join(sum(args.g, []))
|
||||
if args.fno_canonical_system_headers:
|
||||
opts += ' -fno-canonical-system-headers'
|
||||
if args.no_canonical_prefixes:
|
||||
opts += ' -no-canonical-prefixes'
|
||||
if args.sysroot:
|
||||
opts += ' --sysroot ' + args.sysroot[0]
|
||||
|
||||
return opts
|
||||
|
||||
def _update_options(nvcc_options):
|
||||
if NVCC_VERSION in ("7.0",):
|
||||
return nvcc_options
|
||||
|
||||
update_options = { "relaxed-constexpr" : "expt-relaxed-constexpr" }
|
||||
return [ update_options[opt] if opt in update_options else opt
|
||||
for opt in nvcc_options ]
|
||||
|
||||
def GetNvccOptions(argv):
|
||||
"""Collect the -nvcc_options values from argv.
|
||||
|
||||
Args:
|
||||
argv: A list of strings, possibly the argv passed to main().
|
||||
|
||||
Returns:
|
||||
The string that can be passed directly to nvcc.
|
||||
"""
|
||||
|
||||
parser = ArgumentParser()
|
||||
parser.add_argument('-nvcc_options', nargs='*', action='append')
|
||||
|
||||
args, _ = parser.parse_known_args(argv)
|
||||
|
||||
if args.nvcc_options:
|
||||
options = _update_options(sum(args.nvcc_options, []))
|
||||
return ' '.join(['--'+a for a in options])
|
||||
return ''
|
||||
|
||||
|
||||
def InvokeNvcc(argv, log=False):
|
||||
"""Call nvcc with arguments assembled from argv.
|
||||
|
||||
Args:
|
||||
argv: A list of strings, possibly the argv passed to main().
|
||||
log: True if logging is requested.
|
||||
|
||||
Returns:
|
||||
The return value of calling os.system('nvcc ' + args)
|
||||
"""
|
||||
|
||||
host_compiler_options = GetHostCompilerOptions(argv)
|
||||
nvcc_compiler_options = GetNvccOptions(argv)
|
||||
opt_option = GetOptionValue(argv, 'O')
|
||||
m_options = GetOptionValue(argv, 'm')
|
||||
m_options = ''.join([' -m' + m for m in m_options if m in ['32', '64']])
|
||||
include_options = GetOptionValue(argv, 'I')
|
||||
out_file = GetOptionValue(argv, 'o')
|
||||
depfiles = GetOptionValue(argv, 'MF')
|
||||
defines = GetOptionValue(argv, 'D')
|
||||
defines = ''.join([' -D' + define for define in defines])
|
||||
undefines = GetOptionValue(argv, 'U')
|
||||
undefines = ''.join([' -U' + define for define in undefines])
|
||||
std_options = GetOptionValue(argv, 'std')
|
||||
# currently only c++11 is supported by Cuda 7.0 std argument
|
||||
nvcc_allowed_std_options = ["c++11"]
|
||||
std_options = ''.join([' -std=' + define
|
||||
for define in std_options if define in nvcc_allowed_std_options])
|
||||
|
||||
# The list of source files get passed after the -c option. I don't know of
|
||||
# any other reliable way to just get the list of source files to be compiled.
|
||||
src_files = GetOptionValue(argv, 'c')
|
||||
|
||||
# Pass -w through from host to nvcc, but don't do anything fancier with
|
||||
# warnings-related flags, since they're not necessarily the same across
|
||||
# compilers.
|
||||
warning_options = ' -w' if '-w' in argv else ''
|
||||
|
||||
if len(src_files) == 0:
|
||||
return 1
|
||||
if len(out_file) != 1:
|
||||
return 1
|
||||
|
||||
opt = (' -O2' if (len(opt_option) > 0 and int(opt_option[0]) > 0)
|
||||
else ' -g -G')
|
||||
|
||||
includes = (' -I ' + ' -I '.join(include_options)
|
||||
if len(include_options) > 0
|
||||
else '')
|
||||
|
||||
# Unfortunately, there are other options that have -c prefix too.
|
||||
# So allowing only those look like C/C++ files.
|
||||
src_files = [f for f in src_files if
|
||||
re.search('\.cpp$|\.cc$|\.c$|\.cxx$|\.C$', f)]
|
||||
srcs = ' '.join(src_files)
|
||||
out = ' -o ' + out_file[0]
|
||||
|
||||
supported_cuda_compute_capabilities = [ "3.0", "6.0" ]
|
||||
nvccopts = '-D_FORCE_INLINES '
|
||||
for capability in supported_cuda_compute_capabilities:
|
||||
capability = capability.replace('.', '')
|
||||
nvccopts += r'-gencode=arch=compute_%s,\"code=sm_%s,compute_%s\" ' % (
|
||||
capability, capability, capability)
|
||||
nvccopts += ' ' + nvcc_compiler_options
|
||||
nvccopts += undefines
|
||||
nvccopts += defines
|
||||
nvccopts += std_options
|
||||
nvccopts += m_options
|
||||
nvccopts += warning_options
|
||||
|
||||
if depfiles:
|
||||
# Generate the dependency file
|
||||
depfile = depfiles[0]
|
||||
cmd = (NVCC_PATH + ' ' + nvccopts +
|
||||
' --compiler-options "' + host_compiler_options + '"' +
|
||||
' --compiler-bindir=' + GCC_HOST_COMPILER_PATH +
|
||||
' -I .' +
|
||||
' -x cu ' + opt + includes + ' ' + srcs + ' -M -o ' + depfile)
|
||||
if log: Log(cmd)
|
||||
exit_status = os.system(cmd)
|
||||
if exit_status != 0:
|
||||
return exit_status
|
||||
|
||||
cmd = (NVCC_PATH + ' ' + nvccopts +
|
||||
' --compiler-options "' + host_compiler_options + ' -fPIC"' +
|
||||
' --compiler-bindir=' + GCC_HOST_COMPILER_PATH +
|
||||
' -I .' +
|
||||
' -x cu ' + opt + includes + ' -c ' + srcs + out)
|
||||
|
||||
# TODO(zhengxq): for some reason, 'gcc' needs this help to find 'as'.
|
||||
# Need to investigate and fix.
|
||||
cmd = 'PATH=' + PREFIX_DIR + ':$PATH ' + cmd
|
||||
if log: Log(cmd)
|
||||
return os.system(cmd)
|
||||
|
||||
|
||||
def main():
|
||||
parser = ArgumentParser()
|
||||
parser.add_argument('-x', nargs=1)
|
||||
parser.add_argument('--cuda_log', action='store_true')
|
||||
args, leftover = parser.parse_known_args(sys.argv[1:])
|
||||
|
||||
if args.x and args.x[0] == 'cuda':
|
||||
if args.cuda_log: Log('-x cuda')
|
||||
leftover = [pipes.quote(s) for s in leftover]
|
||||
if args.cuda_log: Log('using nvcc')
|
||||
return InvokeNvcc(leftover, log=args.cuda_log)
|
||||
|
||||
# Strip our flags before passing through to the CPU compiler for files which
|
||||
# are not -x cuda. We can't just pass 'leftover' because it also strips -x.
|
||||
# We not only want to pass -x to the CPU compiler, but also keep it in its
|
||||
# relative location in the argv list (the compiler is actually sensitive to
|
||||
# this).
|
||||
cpu_compiler_flags = [flag for flag in sys.argv[1:]
|
||||
if not flag.startswith(('--cuda_log'))]
|
||||
|
||||
return subprocess.call([CPU_COMPILER] + cpu_compiler_flags)
|
||||
|
||||
if __name__ == '__main__':
|
||||
sys.exit(main())
|
71
third_party/toolchains/preconfig/ubuntu16.04/tensorrt6.0/BUILD
vendored
Executable file
71
third_party/toolchains/preconfig/ubuntu16.04/tensorrt6.0/BUILD
vendored
Executable file
@ -0,0 +1,71 @@
|
||||
# NVIDIA TensorRT
|
||||
# A high-performance deep learning inference optimizer and runtime.
|
||||
|
||||
licenses(["notice"])
|
||||
|
||||
load("@local_config_cuda//cuda:build_defs.bzl", "cuda_default_copts")
|
||||
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
|
||||
|
||||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
exports_files(["LICENSE"])
|
||||
|
||||
cc_library(
|
||||
name = "tensorrt_headers",
|
||||
hdrs = [
|
||||
"tensorrt/include/tensorrt_config.h",
|
||||
":tensorrt_include",
|
||||
],
|
||||
include_prefix = "third_party/tensorrt",
|
||||
strip_include_prefix = "tensorrt/include",
|
||||
)
|
||||
|
||||
cc_library(
|
||||
name = "tensorrt",
|
||||
srcs = [":tensorrt_lib"],
|
||||
copts = cuda_default_copts(),
|
||||
data = [":tensorrt_lib"],
|
||||
linkstatic = 1,
|
||||
deps = [
|
||||
":tensorrt_headers",
|
||||
"@local_config_cuda//cuda",
|
||||
],
|
||||
)
|
||||
|
||||
bzl_library(
|
||||
name = "build_defs_bzl",
|
||||
srcs = ["build_defs.bzl"],
|
||||
deps = [
|
||||
"@bazel_skylib//lib:selects",
|
||||
],
|
||||
)
|
||||
|
||||
genrule(
|
||||
name = "tensorrt_lib",
|
||||
outs = [
|
||||
"tensorrt/lib/libnvinfer.so.6",
|
||||
"tensorrt/lib/libnvinfer_plugin.so.6",
|
||||
],
|
||||
cmd = """cp -f "/usr/lib/x86_64-linux-gnu/libnvinfer.so.6" "$(location tensorrt/lib/libnvinfer.so.6)" && \
|
||||
cp -f "/usr/lib/x86_64-linux-gnu/libnvinfer_plugin.so.6" "$(location tensorrt/lib/libnvinfer_plugin.so.6)" """,
|
||||
)
|
||||
|
||||
genrule(
|
||||
name = "tensorrt_include",
|
||||
outs = [
|
||||
"tensorrt/include/NvInfer.h",
|
||||
"tensorrt/include/NvUtils.h",
|
||||
"tensorrt/include/NvInferPlugin.h",
|
||||
"tensorrt/include/NvInferVersion.h",
|
||||
"tensorrt/include/NvInferRuntime.h",
|
||||
"tensorrt/include/NvInferRuntimeCommon.h",
|
||||
"tensorrt/include/NvInferPluginUtils.h",
|
||||
],
|
||||
cmd = """cp -f "/usr/include/x86_64-linux-gnu/NvInfer.h" "$(location tensorrt/include/NvInfer.h)" && \
|
||||
cp -f "/usr/include/x86_64-linux-gnu/NvUtils.h" "$(location tensorrt/include/NvUtils.h)" && \
|
||||
cp -f "/usr/include/x86_64-linux-gnu/NvInferPlugin.h" "$(location tensorrt/include/NvInferPlugin.h)" && \
|
||||
cp -f "/usr/include/x86_64-linux-gnu/NvInferVersion.h" "$(location tensorrt/include/NvInferVersion.h)" && \
|
||||
cp -f "/usr/include/x86_64-linux-gnu/NvInferRuntime.h" "$(location tensorrt/include/NvInferRuntime.h)" && \
|
||||
cp -f "/usr/include/x86_64-linux-gnu/NvInferRuntimeCommon.h" "$(location tensorrt/include/NvInferRuntimeCommon.h)" && \
|
||||
cp -f "/usr/include/x86_64-linux-gnu/NvInferPluginUtils.h" "$(location tensorrt/include/NvInferPluginUtils.h)" """,
|
||||
)
|
203
third_party/toolchains/preconfig/ubuntu16.04/tensorrt6.0/LICENSE
vendored
Executable file
203
third_party/toolchains/preconfig/ubuntu16.04/tensorrt6.0/LICENSE
vendored
Executable file
@ -0,0 +1,203 @@
|
||||
Copyright 2018 The TensorFlow Authors. All rights reserved.
|
||||
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright 2018, The TensorFlow Authors.
|
||||
|
||||
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.
|
2
third_party/toolchains/preconfig/ubuntu16.04/tensorrt6.0/WORKSPACE
vendored
Normal file
2
third_party/toolchains/preconfig/ubuntu16.04/tensorrt6.0/WORKSPACE
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
# DO NOT EDIT: automatically generated WORKSPACE file for tensorrt_configure rule
|
||||
workspace(name = "local_config_tensorrt")
|
5
third_party/toolchains/preconfig/ubuntu16.04/tensorrt6.0/build_defs.bzl
vendored
Executable file
5
third_party/toolchains/preconfig/ubuntu16.04/tensorrt6.0/build_defs.bzl
vendored
Executable file
@ -0,0 +1,5 @@
|
||||
# Build configurations for TensorRT.
|
||||
|
||||
def if_tensorrt(if_true, if_false = []):
|
||||
"""Tests whether TensorRT was enabled during the configure process."""
|
||||
return if_true
|
21
third_party/toolchains/preconfig/ubuntu16.04/tensorrt6.0/tensorrt/include/tensorrt_config.h
vendored
Executable file
21
third_party/toolchains/preconfig/ubuntu16.04/tensorrt6.0/tensorrt/include/tensorrt_config.h
vendored
Executable file
@ -0,0 +1,21 @@
|
||||
/* Copyright 2019 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.
|
||||
==============================================================================*/
|
||||
|
||||
#ifndef TENSORRT_TENSORRT_INCLUDE_CONFIG_H_
|
||||
#define TENSORRT_TENSORRT_INCLUDE_CONFIG_H_
|
||||
|
||||
#define TF_TENSORRT_VERSION "6"
|
||||
|
||||
#endif // TENSORRT_TENSORRT_INCLUDE_CONFIG_H_
|
Loading…
Reference in New Issue
Block a user