Running modern machine learning frameworks on IBM Power servers is a recurring challenge, since the most popular tools have dropped official support for the ppc64le architecture. Google discontinued the prebuilt TensorFlow binaries for the architecture back in 2021, and as a result Power9 users were left stuck on older versions, missing out on important advances in the ecosystem.
In this post we describe how we compiled and ran TensorFlow 2.21 natively on an IBM Power9 server, with full NVIDIA GPU support. We reached the result in two stages: first we built a stable CPU foundation, solving Bazel 7's hermetic build and dozens of C++ incompatibilities; then we replaced the GPU stubs with real CUDA libraries and faced an entirely new class of problems.
What This Work Enables
- Compiling and running TensorFlow 2.21 natively on IBM Power9 (ppc64le) with NVIDIA GPU acceleration;
- Installing the result of this work through a ready to use Conda package, with no need to compile from scratch;
- Using Keras 3 and NumPy 2.0, both incompatible with the TensorFlow 2.14 that was previously available;
- Running inference and training workloads with TensorFlow 2.21 on ppc64le.
Environment
The setup was validated in the following environment:
- IBM Power9 server (AC922);
- ppc64le architecture;
- Operating system: AlmaLinux 8.10;
- GPU: NVIDIA Tesla V100 (compute capability 7.0);
- CUDA 12.4.1 and cuDNN 9.0.0;
- Execution in a container (Docker).
Adaptations We Made
TensorFlow's modern build system (Bazel 7) adopts the hermetic model, which forces the use of prebuilt binaries and of logic tied to the x86_64 and aarch64 architectures and to NVIDIA accelerators. On ppc64le, a build simply fails when it tries to download tools for incompatible architectures. The necessary adaptations concentrated on four fronts, discussed below.
1. Building Bazel 7 and stub repositories
Google does not distribute Bazel 7 for PowerPC, so we had to build it from scratch from the official distribution archive. Next, we created stub repositories, empty folders that satisfy Bazel's dependency declarations without downloading anything, for LLVM, CUDA, ROCm, TensorRT and PyPI, forcing the use of the libraries from the Conda environment. We injected every stub through Bazel's own repository override mechanism, without changing TensorFlow's source code. We deliberately isolated GPU support at this stage, designing a foundation that could be reused once we replaced the stubs with the real CUDA libraries.
2. Compatibility patches in the source code
We ran into 21 incompatibilities specific to the GCC 13 and ppc64le combination, concentrated in three areas: Clang only compilation options rejected by GCC, C++ template ambiguities in XLA and MLIR, and references to CUDA and TensorRT headers, which we replaced with the stubs. We solved each one with a specific patch, preserving TensorFlow's functional logic.
3. Unified CUDA tree and NVCC wrapper
NVIDIA no longer supports the ppc64le architecture: CUDA 12.4.1 and cuDNN 9.0.0 are the last versions published for it. On top of that, NVCC 12.4 only accepts Clang up to version 17 as a host compiler, which forced us to pin that version instead of the system GCC. Since conda-forge distributes CUDA across dozens of separate packages, with headers in separate directories, we built a mirror tree identical to a traditional installation so that TensorFlow would see a clean, conventional environment.
The core of the GPU build is a compiler wrapper. Bazel believes it is calling GCC, but our script intercepts every invocation and decides where it goes: CUDA code goes to the real NVCC, with translation of the options that GCC understands and NVCC does not; ordinary host code goes to Clang 17; and tools that run during the build itself produce empty objects, avoiding any dependency on a CUDA runtime on the build machine. This approach lets us keep TensorFlow's source code untouched and control the compiler entirely from the outside.
Figure 1: Build flowchart for TensorFlow 2.21 with GPU on Power9.
4. Fixing the linker
The linker is the last stage of compilation. It takes the object files generated from each source file, resolves the cross references between them and assembles the final library or executable: when a function calls another one defined in a different file, it is the linker that fills in the target address. In small projects this is trivial, but TensorFlow produces shared libraries hundreds of megabytes in size, and at that scale the limits of the architecture itself start to show up.
Power's ELFv2 ABI (Application Binary Interface) reserves register r2 as a pointer to the TOC (Table of Contents), the section that holds the addresses of global symbols. The code does not reference those addresses directly: it reads them from the TOC using an offset from r2. Since that offset has a limited width, each TOC group covers only a range of entries, and libraries the size of TensorFlow's overflow that limit. The linker then has to create several groups and, on every call that crosses from one group into another, insert a piece of code that saves r2 before the jump and restores it on return.
That restoration was exactly what was failing. The returning function would end up reading the wrong TOC, resolving pointers to invalid addresses and causing a segfault during the static initialization of the CUDA kernels. We used a version of LLD, the LLVM project's linker, patched to restore the pointer correctly, and we manually generated the PPC64 register save and restore stubs that LLD does not synthesize on its own.
The complete step by step guide, including the exact dependency versions, the environment setup, the patches applied and the build script, is documented in our repository.
Installation
For those who have no interest in compiling from scratch, the result is published on the ufcg-ibm Conda channel:
conda create -n tf221 python=3.11 -y
conda activate tf221
conda install -c ufcg-ibm -c conda-forge tensorflow-gpu=2.21.0 -y
For Power9 machines without an NVIDIA GPU, we also keep the tensorflow-cpu=2.21.0 package published, which drops the CUDA and cuDNN dependencies and results in a considerably lighter installation.
Known Limitations
For the sake of transparency, we record two engineering choices in this build that can be considered limitations of the solution. The compatibility window is closed, since we depend on the last versions of CUDA and cuDNN with ppc64le support and there is no upgrade path on this architecture. In addition, we disabled the MLIR generated kernels and opted for the classic C++ template path, with no observed loss of functionality, because the MLIR to PTX generator fails on a ppc64le host.
Conclusion
This work presents a reproducible path for running TensorFlow 2.21 with GPU acceleration on IBM Power9 systems, addressing the absence of official ppc64le support through a set of patches, a compiler wrapper and a linker fix, all packaged in a ready to use Conda distribution. With this, GPU accelerated training and inference become possible again on the architecture with a modern framework, and Keras 3, NumPy 2.0 and a broader Hugging Face Transformers stack come within reach of Power9 users. Our next step is to validate the setup on real workloads, with training of larger models and multi-GPU execution.
This work is part of a collaboration between the Federal University of Campina Grande (UFCG, Brazil) and IBM, within the scope of the Multi-Arq project, dedicated to porting, validating and optimizing applications for the ppc64le architecture.
Resources
#PowerDataandAI