tensorflow/tensorflow
Configuration
Configuration knobs you'll meet most often.
./configure (configure.py)
The script asks the questions and writes .tf_configure.bazelrc. The same answers can be set as environment variables for unattended builds:
| Env var | Purpose |
|---|---|
PYTHON_BIN_PATH |
Path to the Python interpreter to build against. |
TF_NEED_CUDA |
1 to enable CUDA support. |
TF_CUDA_PATHS |
Comma-separated list of CUDA install roots. |
TF_CUDA_VERSION |
CUDA version (e.g. 12.5). |
TF_CUDNN_VERSION |
cuDNN version. |
TF_CUDA_COMPUTE_CAPABILITIES |
Compute capabilities to compile for, e.g. 8.0,9.0. |
TF_NEED_ROCM |
1 for ROCm/AMD GPU support. |
TF_NEED_TENSORRT |
1 to integrate TensorRT. |
TF_NEED_MPI |
1 for MPI distributed support. |
TF_DOWNLOAD_CLANG |
1 to use Clang shipped via Bazel. |
CC_OPT_FLAGS |
Optimization flags (default -Wno-sign-compare -mavx). |
TF_SET_ANDROID_WORKSPACE |
1 to set up Android NDK paths. |
Source: configure.py at the repo root (~50 KB).
.bazelrc configs
The .bazelrc (~60 KB) defines named configurations you pass via --config=<name> to bazel build/test:
| Config | Effect |
|---|---|
--config=opt |
Release optimization flags |
--config=cuda |
Enable CUDA build |
--config=cuda_clang |
Use Clang as CUDA compiler |
--config=rocm |
Enable ROCm |
--config=mkl |
Use Intel MKL/oneDNN paths |
--config=mkl_aarch64 |
MKL on aarch64 |
--config=tflite_with_xnnpack |
Build TFLite with XNNPACK delegate |
--config=monolithic |
Statically link runtime into single binary |
--config=v1 |
Build with TF1 API surface |
--config=asan / msan / tsan |
Sanitizer builds |
--config=dynamic_kernels |
Make op kernels dynamically loadable |
--config=android_arm / android_arm64 / android_x86_64 |
Android cross-compiles |
--config=ios |
iOS cross-compile |
Plus per-CPU configs (--config=avx2_linux, etc.). The full list is in .bazelrc.
Runtime environment variables
Variables that influence behaviour at runtime (not build time):
| Var | Effect |
|---|---|
TF_CPP_MIN_LOG_LEVEL |
Suppress logs at or below severity (0 info, 1 warn, 2 err, 3 none). |
TF_CPP_VMODULE |
Per-file VLOG verbosity (e.g. executor=2,direct_session=2). |
CUDA_VISIBLE_DEVICES |
NVIDIA-driver level GPU masking; respected by TF. |
TF_FORCE_GPU_ALLOW_GROWTH |
If true, BFC allocator grows on demand instead of pre-reserving. |
TF_GPU_ALLOCATOR |
cuda_malloc_async to use the async allocator. |
TF_USE_TFRT |
Switch some paths to TFRT. |
TF_USE_MLRT |
Use the MLRT runtime (a TFRT variant). |
TF_NUM_INTEROP_THREADS |
Inter-op pool size. |
TF_NUM_INTRAOP_THREADS |
Intra-op pool size. |
TF_DETERMINISTIC_OPS |
Force deterministic kernels where possible. |
TF_DUMP_GRAPH_PREFIX |
Where to dump pre/post-Grappler graphs. |
XLA_FLAGS |
Pass-through to XLA (e.g. --xla_dump_to=...). |
TF_ENABLE_ONEDNN_OPTS |
Toggle oneDNN code paths in CPU kernels. |
TF_USE_CUDNN_DETERMINISTIC |
Force deterministic cuDNN paths. |
TF_DATA_EXPERIMENT_OPT_IN |
Comma list of experimental tf.data optimizations to enable. |
Use tf.config.experimental.* Python APIs to query and set most of these at runtime where applicable.
Python-side runtime config
The tf.config module:
tf.config.list_physical_devices("GPU")— see what TF detects.tf.config.experimental.set_memory_growth(device, True)— equivalent toTF_FORCE_GPU_ALLOW_GROWTH=1.tf.config.threading.set_inter_op_parallelism_threads(n)/intra_op_parallelism_threads.tf.config.optimizer.set_jit(True)— enable XLA auto-clustering.tf.config.optimizer.set_experimental_options({...})— toggle individual Grappler passes.tf.debugging.set_log_device_placement(True)— print every op's device.
Useful build targets
| Target | Output |
|---|---|
//tensorflow/tools/pip_package:wheel |
Pip wheel. |
//tensorflow:libtensorflow.so |
C API shared lib. |
//tensorflow:libtensorflow_cc.so |
C++ API shared lib. |
//tensorflow/lite:libtensorflowlite.so |
TFLite shared lib. |
//tensorflow/lite/java:tensorflow-lite |
Android AAR. |
//tensorflow/lite/tools/benchmark:benchmark_model |
TFLite benchmark binary. |
Related
- how-to-contribute/tooling — what
./configureand Bazel actually do. - how-to-contribute/getting-started — full build walkthrough.
Built by Factory AutoWiki from public repository content. It is a generated preview for codebase exploration, not source-maintained documentation.