pytorch
/
.bazelrc
114 строк · 5.5 Кб
1build --cxxopt=--std=c++17
2build --copt=-I.
3# Bazel does not support including its cc_library targets as system
4# headers. We work around this for generated code
5# (e.g. c10/macros/cmake_macros.h) by making the generated directory a
6# system include path.
7build --copt=-isystem --copt bazel-out/k8-fastbuild/bin
8build --copt=-isystem --copt bazel-out/darwin-fastbuild/bin
9build --experimental_ui_max_stdouterr_bytes=2048576
10
11# Configuration to disable tty features for environments like CI
12build:no-tty --curses no
13build:no-tty --progress_report_interval 10
14build:no-tty --show_progress_rate_limit 10
15
16# Build with GPU support by default.
17build --define=cuda=true
18# rules_cuda configuration
19build --@rules_cuda//cuda:enable_cuda
20build --@rules_cuda//cuda:cuda_targets=sm_52
21build --@rules_cuda//cuda:compiler=nvcc
22build --repo_env=CUDA_PATH=/usr/local/cuda
23
24# Configuration to build without GPU support
25build:cpu-only --define=cuda=false
26# define a separate build folder for faster switching between configs
27build:cpu-only --platform_suffix=-cpu-only
28# See the note on the config-less build for details about why we are
29# doing this. We must also do it for the "-cpu-only" platform suffix.
30build --copt=-isystem --copt=bazel-out/k8-fastbuild-cpu-only/bin
31# rules_cuda configuration
32build:cpu-only --@rules_cuda//cuda:enable_cuda=False
33
34# Definition of --config=shell
35# interactive shell immediately before execution
36build:shell --run_under="//tools/bazel_tools:shellwrap"
37
38# Disable all warnings for external repositories. We don't care about
39# their warnings.
40build --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
68build --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# We intentionally use #pragma unroll, which is compiler specific.
73build --per_file_copt='^//.*\.(cpp|cc)$'@-Wno-error=unknown-pragmas
74
75build --per_file_copt='^//.*\.(cpp|cc)$'@-Werror=extra
76# The following warnings come from -Wextra. We downgrade them from error
77# to warnings here.
78#
79# unused-parameter-compare has a tremendous amount of violations in the
80# codebase. It will be a lot of work to fix them, just disable it for
81# now.
82build --per_file_copt='^//.*\.(cpp|cc)$'@-Wno-unused-parameter
83# missing-field-parameters has both a large number of violations in
84# the codebase, but it also is used pervasively in the Python C
85# API. There are a couple of catches though:
86# * we use multiple versions of the Python API and hence have
87# potentially multiple different versions of each relevant
88# struct. They may have different numbers of fields. It will be
89# unwieldy to support multiple versions in the same source file.
90# * Python itself for many of these structs recommends only
91# initializing a subset of the fields. We should respect the API
92# usage conventions of our dependencies.
93#
94# Hence, we just disable this warning altogether. We may want to clean
95# up some of the clear-cut cases that could be risky, but we still
96# likely want to have this disabled for the most part.
97build --per_file_copt='^//.*\.(cpp|cc)$'@-Wno-missing-field-initializers
98
99build --per_file_copt='^//.*\.(cpp|cc)$'@-Wno-unused-function
100build --per_file_copt='^//.*\.(cpp|cc)$'@-Wno-unused-variable
101
102build --per_file_copt='//:aten/src/ATen/RegisterCompositeExplicitAutograd\.cpp$'@-Wno-error=unused-function
103build --per_file_copt='//:aten/src/ATen/RegisterCompositeImplicitAutograd\.cpp$'@-Wno-error=unused-function
104build --per_file_copt='//:aten/src/ATen/RegisterMkldnnCPU\.cpp$'@-Wno-error=unused-function
105build --per_file_copt='//:aten/src/ATen/RegisterNestedTensorCPU\.cpp$'@-Wno-error=unused-function
106build --per_file_copt='//:aten/src/ATen/RegisterQuantizedCPU\.cpp$'@-Wno-error=unused-function
107build --per_file_copt='//:aten/src/ATen/RegisterSparseCPU\.cpp$'@-Wno-error=unused-function
108build --per_file_copt='//:aten/src/ATen/RegisterSparseCsrCPU\.cpp$'@-Wno-error=unused-function
109build --per_file_copt='//:aten/src/ATen/RegisterNestedTensorMeta\.cpp$'@-Wno-error=unused-function
110build --per_file_copt='//:aten/src/ATen/RegisterSparseMeta\.cpp$'@-Wno-error=unused-function
111build --per_file_copt='//:aten/src/ATen/RegisterQuantizedMeta\.cpp$'@-Wno-error=unused-function
112build --per_file_copt='//:aten/src/ATen/RegisterZeroTensor\.cpp$'@-Wno-error=unused-function
113build --per_file_copt='//:torch/csrc/lazy/generated/RegisterAutogradLazy\.cpp$'@-Wno-error=unused-function
114build --per_file_copt='//:torch/csrc/lazy/generated/RegisterLazy\.cpp$'@-Wno-error=unused-function
115