aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/contrib/nccl/BUILD
blob: 9a9d4802608dc94bf70082e1585de3890a5dbabf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
# Description:
#   Wrap NVIDIA (https://github.com/NVIDIA/nccl) NCCL with tensorflow ops.
#   APIs are meant to change over time.

package(default_visibility = ["//tensorflow:__subpackages__"])

licenses(["notice"])  # Apache 2.0

exports_files(["LICENSE"])

load(
    "//tensorflow:tensorflow.bzl",
    "tf_custom_op_library",
    "tf_gen_op_libs",
    "tf_gen_op_wrapper_py",
)
load("//tensorflow:tensorflow.bzl", "tf_cuda_cc_test")
load("//tensorflow:tensorflow.bzl", "cuda_py_test")
load("@local_config_cuda//cuda:build_defs.bzl", "if_cuda")
load("//tensorflow:tensorflow.bzl", "tf_kernel_library")
load("//tensorflow:tensorflow.bzl", "tf_custom_op_py_library")
load("//tensorflow:tensorflow.bzl", "if_not_windows_cuda")

tf_custom_op_library(
    name = "python/ops/_nccl_ops.so",
    srcs = [
        "ops/nccl_ops.cc",
    ],
    gpu_srcs = if_not_windows_cuda([
        "kernels/nccl_manager.cc",
        "kernels/nccl_manager.h",
        "kernels/nccl_ops.cc",
    ]),
    deps = [] + if_cuda([
        "@local_config_nccl//:nccl",
        "//tensorflow/core:gpu_headers_lib",
        "//tensorflow/core:protos_all_cc",
        "//tensorflow/core:protos_all_proto_text",
    ]),
)

tf_cuda_cc_test(
    name = "nccl_manager_test",
    size = "medium",
    srcs = if_cuda(
        [
            "kernels/nccl_manager.cc",
            "kernels/nccl_manager.h",
            "kernels/nccl_manager_test.cc",
        ],
        [],
    ),
    # Disabled on jenkins until errors finding nvmlShutdown are found.
    tags = [
        "manual",
        "multi_gpu",
        "no_oss",
        "noguitar",
        "notap",
    ],
    deps =
        if_cuda([
            "@local_config_nccl//:nccl",
            "//tensorflow/core:cuda",
            "//tensorflow/core:test",
            "//tensorflow/core:test_main",
            "//tensorflow/core:testlib",
        ]),
)

tf_kernel_library(
    name = "nccl_kernels",
    srcs = if_cuda([
        "kernels/nccl_manager.cc",
        "kernels/nccl_manager.h",
        "kernels/nccl_ops.cc",
        "kernels/nccl_rewrite.cc",
    ]),
    deps = if_cuda([
        "@local_config_nccl//:nccl",
        "//tensorflow/core:core_cpu",
        "//tensorflow/core:framework",
        "//tensorflow/core:gpu_headers_lib",
        "//tensorflow/core:lib",
        "//tensorflow/core:stream_executor",
    ]),
    alwayslink = 1,
)

tf_gen_op_libs(
    op_lib_names = ["nccl_ops"],
    deps = [
        "//tensorflow/core:lib",
    ],
)

tf_gen_op_wrapper_py(
    name = "nccl_ops",
    deps = [":nccl_ops_op_lib"],
)

# Test only nccl ops lib without dso to test behavior when NCCL lib is not
# installed. See nccl_dependency_test for more details.
#
# Users should use the public nccl_py lib that also adds the dso.
tf_custom_op_py_library(
    name = "nccl_ops_lib_without_dso",
    srcs = [
        "__init__.py",
        "python/ops/nccl_ops.py",
    ],
    kernels = if_cuda([":nccl_kernels"]) + [
        ":nccl_ops_op_lib",
    ],
    deps = [
        ":nccl_ops",
        "//tensorflow/contrib/util:util_py",
        "//tensorflow/python:device",
        "//tensorflow/python:framework_ops",
        "//tensorflow/python:platform",
        "//tensorflow/python:util",
        "//tensorflow/python/eager:context",
    ],
)

tf_custom_op_py_library(
    name = "nccl_py",
    dso = [":python/ops/_nccl_ops.so"],
    visibility = ["//visibility:public"],
    deps = [
        ":nccl_ops_lib_without_dso",
    ],
)

cuda_py_test(
    name = "nccl_ops_test",
    size = "small",
    srcs = ["python/ops/nccl_ops_test.py"],
    additional_deps = [
        ":nccl_py",
        "//tensorflow/python:array_ops",
        "//tensorflow/python:client_testlib",
        "//tensorflow/python:framework_for_generated_wrappers",
        "//tensorflow/python:framework_test_lib",
        "//tensorflow/python:platform_test",
    ],
    # Disabled on jenkins until errors finding nvmlShutdown are found.
    tags = [
        "manual",
        "multi_gpu",
        "no_oss",
        "noguitar",
        "notap",
    ],
)

cuda_py_test(
    name = "nccl_dependency_test",
    size = "small",
    srcs = ["python/ops/nccl_dependency_test.py"],
    additional_deps = [
        ":nccl_ops_lib_without_dso",
        "//tensorflow/python:constant_op",
        "//tensorflow/python:errors",
        "//tensorflow/python:framework_ops",
        "//tensorflow/python:util",
        "//tensorflow/python:client_testlib",
        "//tensorflow/python:platform_test",
    ],
    # Disable this test internally as static linking is used internally and only
    # run for OSS to verify that NCCL is an optional dynamic dependency.
    tags = [
        "manual",
        "noguitar",
        "notap",
    ],
)