TensorFlow
GPU
CXXABI_1.3.8
Installation
Troubleshooting

'CXXABI_1.3.8' not found in tensorflow-gpu - install from source

ML System Design practice on Codemia

Design recommenders, ranking systems and training pipelines the way ML interviews actually ask for them, with worked solutions.

Practice ML system design

Introduction

The CXXABI_1.3.8 not found error occurs when TensorFlow's compiled binaries require a newer C++ ABI (Application Binary Interface) version than what your system's libstdc++ provides. CXXABI_1.3.8 is provided by GCC 4.9+ and its associated libstdc++.so.6. The fix is to upgrade your GCC/libstdc++ version, set LD_LIBRARY_PATH to a newer libstdc++, or build TensorFlow from source with your existing compiler.

The Error

bash
$ python -c "import tensorflow"
ImportError: /usr/lib/x86_64-linux-gnu/libstdc++.so.6: version 'CXXABI_1.3.8' not found
(required by /path/to/tensorflow/python/_pywrap_tensorflow_internal.so)

This means the TensorFlow binary was compiled with a newer GCC than what your system has installed.

Diagnosing the Problem

bash
1# Check which CXXABI versions your system supports
2strings /usr/lib/x86_64-linux-gnu/libstdc++.so.6 | grep CXXABI
3# CXXABI_1.3
4# CXXABI_1.3.1
5# ...
6# CXXABI_1.3.7    ← If this is the highest, you're missing 1.3.8
7
8# Check your GCC version
9gcc --version
10# gcc 4.8.5 ← Too old, needs 4.9+ for CXXABI_1.3.8
11
12# CXXABI version → minimum GCC version mapping:
13# CXXABI_1.3.7  → GCC 4.8
14# CXXABI_1.3.8  → GCC 4.9
15# CXXABI_1.3.9  → GCC 5.1
16# CXXABI_1.3.11 → GCC 7.1
17# CXXABI_1.3.13 → GCC 10.1

Fix 1: Upgrade GCC and libstdc++

bash
1# Ubuntu/Debian — install a newer GCC
2sudo apt update
3sudo apt install gcc-9 g++-9 libstdc++-9-dev
4
5# Or use a PPA for the latest GCC
6sudo add-apt-repository ppa:ubuntu-toolchain-r/test
7sudo apt update
8sudo apt install gcc-11 g++-11
9
10# Set as default
11sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-11 100
12sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-11 100
13
14# Verify
15strings /usr/lib/x86_64-linux-gnu/libstdc++.so.6 | grep CXXABI_1.3.8
16# CXXABI_1.3.8   ← Now available
bash
1# CentOS/RHEL — use devtoolset
2sudo yum install centos-release-scl
3sudo yum install devtoolset-9
4
5# Activate
6scl enable devtoolset-9 bash
7
8# Or add to .bashrc for permanent use
9echo "source /opt/rh/devtoolset-9/enable" >> ~/.bashrc

Fix 2: Point LD_LIBRARY_PATH to a Newer libstdc++

If you have a newer GCC installed but the system still uses the old libstdc++:

bash
1# Find the newer libstdc++
2find / -name "libstdc++.so.6*" 2>/dev/null
3# /opt/rh/devtoolset-9/root/usr/lib/gcc/x86_64-linux-gnu/9/libstdc++.so.6
4# /usr/lib/x86_64-linux-gnu/libstdc++.so.6   ← old one
5
6# Point to the newer version
7export LD_LIBRARY_PATH=/opt/rh/devtoolset-9/root/usr/lib/gcc/x86_64-linux-gnu/9:$LD_LIBRARY_PATH
8
9# Or if you installed GCC via conda
10export LD_LIBRARY_PATH=$CONDA_PREFIX/lib:$LD_LIBRARY_PATH
11
12# Verify
13python -c "import tensorflow; print(tensorflow.__version__)"

Add the export to your .bashrc or .zshrc to make it permanent.

Fix 3: Install via Conda (Bundles libstdc++)

Conda installs its own libstdc++ that includes the required CXXABI versions:

bash
1# Create a fresh environment
2conda create -n tf python=3.10
3conda activate tf
4
5# Install TensorFlow — conda bundles compatible libstdc++
6conda install -c conda-forge tensorflow-gpu
7
8# Verify
9python -c "import tensorflow as tf; print(tf.__version__)"

Fix 4: Build TensorFlow from Source

Build TensorFlow with your system's compiler to match the available CXXABI:

bash
1# Install Bazel (TensorFlow's build system)
2# Check https://www.tensorflow.org/install/source for compatible versions
3
4# Clone TensorFlow
5git clone https://github.com/tensorflow/tensorflow.git
6cd tensorflow
7git checkout v2.15.0  # Choose your version
8
9# Configure — answer prompts for CUDA, cuDNN, etc.
10./configure
11
12# Build the pip package
13bazel build --config=opt --config=cuda //tensorflow/tools/pip_package:build_pip_package
14
15# Create and install the wheel
16./bazel-bin/tensorflow/tools/pip_package/build_pip_package /tmp/tensorflow_pkg
17pip install /tmp/tensorflow_pkg/tensorflow-*.whl

Building from source ensures TensorFlow links against your system's libstdc++ and avoids the CXXABI mismatch entirely.

Fix 5: Use Docker (Avoids System Issues)

bash
1# Official TensorFlow GPU image includes all dependencies
2docker run --gpus all -it tensorflow/tensorflow:latest-gpu bash
3
4# Inside the container
5python -c "import tensorflow as tf; print(tf.config.list_physical_devices('GPU'))"

Verifying the Fix

bash
1# Check that the required CXXABI is available
2python -c "
3import ctypes
4lib = ctypes.CDLL('libstdc++.so.6')
5print('libstdc++ loaded successfully')
6"
7
8# Full TensorFlow test
9python -c "
10import tensorflow as tf
11print(f'TensorFlow version: {tf.__version__}')
12print(f'GPU available: {tf.config.list_physical_devices(\"GPU\")}')
13print(f'Built with CUDA: {tf.test.is_built_with_cuda()}')
14"

Common Pitfalls

  • Upgrading GCC without updating libstdc++: Installing a new GCC compiler does not always install the matching libstdc++.so.6. On CentOS/RHEL, devtoolset installs the library in a non-standard path that is not on LD_LIBRARY_PATH by default. Run scl enable devtoolset-N bash or set LD_LIBRARY_PATH explicitly.
  • Mixing Conda and system libraries: When using Conda with TensorFlow, the system's libstdc++ may take precedence over Conda's newer version. Set LD_LIBRARY_PATH=$CONDA_PREFIX/lib:$LD_LIBRARY_PATH to ensure Conda's libraries are found first.
  • Not cleaning previous builds: When building TensorFlow from source after a failed attempt, stale build artifacts can cause linking errors. Run bazel clean --expunge before rebuilding to start fresh.
  • Wrong CUDA/cuDNN versions: Building from source requires specific CUDA and cuDNN versions for each TensorFlow version. Check the official build compatibility table at tensorflow.org/install/source. Mismatched versions cause cryptic linker errors beyond the CXXABI issue.
  • Copying libstdc++.so.6 from another system: Copying a libstdc++.so.6 binary from a different machine may not work due to glibc version mismatches. The library must be compatible with your system's glibc. Install the matching libstdc++ package instead of copying binaries.

Summary

  • CXXABI_1.3.8 not found means your libstdc++ is too old for the TensorFlow binary
  • Upgrade GCC to 4.9+ (for CXXABI_1.3.8) or 5.1+ (for CXXABI_1.3.9) and install the matching libstdc++
  • Set LD_LIBRARY_PATH to point to the newer libstdc++.so.6 if it is installed in a non-standard location
  • Use Conda to install TensorFlow with bundled compatible libraries
  • Build TensorFlow from source to match your system's exact compiler version
  • Use Docker (tensorflow/tensorflow:latest-gpu) to avoid all system dependency issues

Related reading
Free course
Beginner
7 lessons
2 hours
Tackling System Design Interview Problems

A short course that equips you with the skills to approach system design interviews methodically.

Start the free course
Track what you have practised

A free account saves your progress, solutions and study plan across every problem on Codemia.

ML System Design practice on Codemia

Design recommenders, ranking systems and training pipelines the way ML interviews actually ask for them, with worked solutions.

Practice ML system design

All Rights Reserved.