TensorFlow
GPU support
./configure
machine learning
installation guide

where is the ./configure of TensorFlow and how to enable the GPU support?

Master System Design with Codemia

Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.

Introduction

TensorFlow can be installed with prebuilt packages, but advanced users sometimes need to build it from source. That is the case where ./configure matters, because it prepares a source checkout for Bazel and lets you opt into CUDA support for NVIDIA GPUs.

Where ./configure Actually Lives

If you install TensorFlow with pip, there is no ./configure step. The script exists only in the TensorFlow source repository, so the first step is cloning the project:

bash
git clone https://github.com/tensorflow/tensorflow.git
cd tensorflow
ls configure configure.py

At that point you can run either:

bash
./configure

or:

bash
python configure.py

Both scripts ask a series of questions about your Python interpreter, compiler, optional accelerators, and library locations. The official build guide still documents this flow for source builds. If you are only trying to use TensorFlow, not modify or package it, the simpler path is usually:

bash
python -m pip install tensorflow

That installs an official wheel and avoids the Bazel toolchain entirely.

How GPU Support Fits Into the Build

GPU support is mostly a Linux concern in current TensorFlow releases. The official install docs note that macOS does not have official TensorFlow GPU support, and Windows users usually rely on WSL2 for current GPU workflows. When you build from source on Linux, ./configure asks whether CUDA should be enabled.

The rough flow looks like this:

  1. Install a supported Python version.
  2. Install Bazel or Bazelisk.
  3. Install the NVIDIA driver.
  4. Install the CUDA and cuDNN versions expected by the TensorFlow branch you are building.
  5. Run ./configure and answer Y to the CUDA prompt.
  6. Build with Bazel using a CUDA config.

A typical session looks like this:

bash
./configure

Example answers during configuration:

text
1Please specify the location of python. [Default is /usr/bin/python3]:
2Do you wish to build TensorFlow with CUDA support? [y/N]: y
3Please specify the CUDA SDK version you want to use. [Leave empty to default]:
4Please specify the cuDNN version you want to use. [Leave empty to default]:
5Please specify the comma-separated list of CUDA compute capabilities you want to build with:

Those answers update build settings that Bazel later consumes.

Building a GPU-Enabled Wheel

After configuration, build the wheel with Bazel. A common command is:

bash
1bazel build //tensorflow/tools/pip_package:wheel \
2  --repo_env=USE_PYWRAP_RULES=1 \
3  --repo_env=WHEEL_NAME=tensorflow \
4  --config=cuda \
5  --config=cuda_wheel

When the build finishes, install the generated wheel:

bash
python -m pip install bazel-bin/tensorflow/tools/pip_package/wheel_house/tensorflow-*.whl

Then verify that TensorFlow can see your GPU:

python
1import tensorflow as tf
2
3gpus = tf.config.list_physical_devices("GPU")
4print("Visible GPUs:", gpus)

If the list is empty, the package may be installed correctly while the runtime libraries are still missing or incompatible.

When You Do Not Need to Build From Source

Many questions about ./configure come from users who only want GPU acceleration, not a custom build. In that case, build-from-source is often unnecessary. The official pip installation path is much easier to maintain because the TensorFlow team publishes wheels with the expected dependency set for supported platforms.

The usual workflow is:

bash
1python -m venv .venv
2source .venv/bin/activate
3python -m pip install --upgrade pip
4python -m pip install tensorflow
5python -c "import tensorflow as tf; print(tf.config.list_physical_devices('GPU'))"

If that already detects the GPU, stop there. Source builds only make sense when you need a custom compiler setup, a patched TensorFlow branch, unsupported architectures, or exact control over the produced wheel.

Common Pitfalls

The most common mistake is looking for ./configure inside a pip installation. It is not part of the installed package. Clone the source repository first if you want that script.

Another frequent issue is mismatched CUDA and cuDNN versions. TensorFlow builds and runs against a specific set of libraries, so using a different CUDA installation can lead to link errors or a runtime that starts but does not expose any GPUs.

Users also forget that ./configure is not the build itself. It only records settings. You still need a Bazel build command with CUDA-related flags.

Finally, platform expectations matter. Current official guidance is much better for Linux than for native Windows or macOS GPU builds. If your goal is simply training on an NVIDIA card, Linux or WSL2 is usually the least painful route.

Summary

  • './configure exists in the TensorFlow source repository, not in a pip installation.'
  • Use it when building TensorFlow from source with Bazel.
  • Enable GPU support by answering Y to CUDA questions and building with --config=cuda.
  • Verify the result with tf.config.list_physical_devices("GPU").
  • Prefer official wheels unless you truly need a custom TensorFlow build.

Course illustration
Course illustration

All Rights Reserved.