@@ -13,15 +13,100 @@ build:no-tty --curses no
13
13
build:no-tty --progress_report_interval 10
14
14
build:no-tty --show_progress_rate_limit 10
15
15
16
- # Configuration to build with GPU support
17
- build:gpu --define=cuda=true
16
+ # Build with GPU support by default.
17
+ build --define=cuda=true
18
+ # rules_cuda configuration
19
+ build --@rules_cuda//cuda:enable_cuda
20
+ build --@rules_cuda//cuda:cuda_targets=sm_52
21
+ build --@rules_cuda//cuda:compiler=nvcc
22
+ build --repo_env=CUDA_PATH=/usr/local/cuda
23
+
24
+ # Configuration to build without GPU support
25
+ build:cpu-only --define=cuda=false
18
26
# define a separate build folder for faster switching between configs
19
- build:gpu --platform_suffix=-gpu
27
+ build:cpu-only --platform_suffix=-cpu-only
20
28
# See the note on the config-less build for details about why we are
21
- # doing this. We must also do it for the "-gpu " platform suffix.
22
- build --copt=-isystem --copt=bazel-out/k8-fastbuild-gpu /bin
29
+ # doing this. We must also do it for the "-cpu-only " platform suffix.
30
+ build --copt=-isystem --copt=bazel-out/k8-fastbuild-cpu-only /bin
23
31
# rules_cuda configuration
24
- build:gpu --@rules_cuda//cuda:enable_cuda
25
- build:gpu --@rules_cuda//cuda:cuda_targets=sm_52
26
- build:gpu --@rules_cuda//cuda:compiler=nvcc
27
- build:gpu --repo_env=CUDA_PATH=/usr/local/cuda
32
+ build:cpu-only --@rules_cuda//cuda:enable_cuda=False
33
+
34
+ # Definition of --config=shell
35
+ # interactive shell immediately before execution
36
+ build:shell --run_under="//tools/bazel_tools:shellwrap"
37
+
38
+ # Disable all warnings for external repositories. We don't care about
39
+ # their warnings.
40
+ build --per_file_copt=^external/@-w
41
+
42
+ # Set additional warnings to error level.
43
+ #
44
+ # Implementation notes:
45
+ # * we use file extensions to determine if we are using the C++
46
+ # compiler or the cuda compiler
47
+ # * we use ^// at the start of the regex to only permit matching
48
+ # PyTorch files. This excludes external repos.
49
+ #
50
+ # Note that because this is logically a command-line flag, it is
51
+ # considered the word on what warnings are enabled. This has the
52
+ # unfortunate consequence of preventing us from disabling an error at
53
+ # the target level because those flags will come before these flags in
54
+ # the action invocation. Instead we provide per-file exceptions after
55
+ # this.
56
+ #
57
+ # On the bright side, this means we don't have to more broadly apply
58
+ # the exceptions to an entire target.
59
+ #
60
+ # Looking for CUDA flags? We have a cu_library macro that we can edit
61
+ # directly. Look in //tools/rules:cu.bzl for details. Editing the
62
+ # macro over this has the following advantages:
63
+ # * making changes does not require discarding the Bazel analysis
64
+ # cache
65
+ # * it allows for selective overrides on individual targets since the
66
+ # macro-level opts will come earlier than target level overrides
67
+
68
+ build --per_file_copt='^//.*\.(cpp|cc)$'@-Werror=all
69
+ # The following warnings come from -Wall. We downgrade them from error
70
+ # to warnings here.
71
+ #
72
+ # sign-compare has a tremendous amount of violations in the
73
+ # codebase. It will be a lot of work to fix them, just disable it for
74
+ # now.
75
+ build --per_file_copt='^//.*\.(cpp|cc)$'@-Wno-sign-compare
76
+ # We intentionally use #pragma unroll, which is compiler specific.
77
+ build --per_file_copt='^//.*\.(cpp|cc)$'@-Wno-error=unknown-pragmas
78
+
79
+ build --per_file_copt='^//.*\.(cpp|cc)$'@-Werror=extra
80
+ # The following warnings come from -Wextra. We downgrade them from error
81
+ # to warnings here.
82
+ #
83
+ # unused-parameter-compare has a tremendous amount of violations in the
84
+ # codebase. It will be a lot of work to fix them, just disable it for
85
+ # now.
86
+ build --per_file_copt='^//.*\.(cpp|cc)$'@-Wno-unused-parameter
87
+ # missing-field-parameters has both a large number of violations in
88
+ # the codebase, but it also is used pervasively in the Python C
89
+ # API. There are a couple of catches though:
90
+ # * we use multiple versions of the Python API and hence have
91
+ # potentially multiple different versions of each relevant
92
+ # struct. They may have different numbers of fields. It will be
93
+ # unwieldy to support multiple versions in the same source file.
94
+ # * Python itself for many of these structs recommends only
95
+ # initializing a subset of the fields. We should respect the API
96
+ # usage conventions of our dependencies.
97
+ #
98
+ # Hence, we just disable this warning altogether. We may want to clean
99
+ # up some of the clear-cut cases that could be risky, but we still
100
+ # likely want to have this disabled for the most part.
101
+
B41A
build --per_file_copt='^//.*\.(cpp|cc)$'@-Wno-missing-field-initializers
102
+
103
+ build --per_file_copt='//:aten/src/ATen/RegisterCompositeExplicitAutograd\.cpp$'@-Wno-error=unused-function
104
+ build --per_file_copt='//:aten/src/ATen/RegisterCompositeImplicitAutograd\.cpp$'@-Wno-error=unused-function
105
+ build --per_file_copt='//:aten/src/ATen/RegisterMkldnnCPU\.cpp$'@-Wno-error=unused-function
106
+ build --per_file_copt='//:aten/src/ATen/RegisterNestedTensorCPU\.cpp$'@-Wno-error=unused-function
107
+ build --per_file_copt='//:aten/src/ATen/RegisterQuantizedCPU\.cpp$'@-Wno-error=unused-function
108
+ build --per_file_copt='//:aten/src/ATen/RegisterSparseCPU\.cpp$'@-Wno-error=unused-function
109
+ build --per_file_copt='//:aten/src/ATen/RegisterSparseCsrCPU\.cpp$'@-Wno-error=unused-function
110
+ build --per_file_copt='//:aten/src/ATen/RegisterZeroTensor\.cpp$'@-Wno-error=unused-function
111
+ build --per_file_copt='//:torch/csrc/lazy/generated/RegisterAutogradLazy\.cpp$'@-Wno-error=unused-function
112
+ build --per_file_copt='//:torch/csrc/lazy/generated/RegisterLazy\.cpp$'@-Wno-error=unused-function
0 commit comments