This project provides a Docker-based environment for building TensorFlow from source with CUDA 12.8 and cuDNN support on Ubuntu 24.04. It automates the setup, build, and installation of a custom TensorFlow wheel with GPU acceleration.
- Builds TensorFlow from source using Bazel and Clang 20
- CUDA 12.8.1 and cuDNN 9.8 support
- Python 3 virtual environment with the built TensorFlow wheel installed
- Reproducible environment using Docker
- Docker (with NVIDIA Container Toolkit for GPU support)
- NVIDIA GPU with compatible drivers
docker build --progress=plain .docker run -it --rm --gpus all $(docker build -q .)This will drop you into a shell inside the container, with TensorFlow built and installed in a Python virtual environment at /workspace/venv.
Activate the virtual environment and test TensorFlow:
source /workspace/venv/bin/activate
python -c "import tensorflow as tf; print(tf.reduce_sum(tf.random.normal([1000, 1000])))"You can also check CUDA and GPU status:
nvcc --version
nvidia-smiDockerfile: Defines the build environment and steps to build/install TensorFlow..tf_configure.bazelrc: Bazel build configuration for CUDA, cuDNN, and Clang.readme.md: Project documentation and usage instructions.
- To change the TensorFlow version, modify the
git clonestep in the Dockerfile. - To adjust CUDA/cuDNN versions, update the base image and Bazel config.
docker run -it --rm --gpus all $(docker build -q .)
docker build --progress=plain .
nvcc --version
nvidia-smi
python -c "import tensorflow as tf; print(tf.reduce_sum(tf.random.normal([1000, 1000])))"