TensorFlow
libcudart.so.7.5
shared object file
error solution
Linux troubleshooting

TensorFlow libcudart.so.7.5 cannot open shared object file No such file or directory

Master System Design with Codemia

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

Introduction

The error libcudart.so.7.5: cannot open shared object file: No such file or directory appears when a TensorFlow build expects CUDA runtime version 7.5, but your system does not provide that exact shared library in the dynamic loader path. This is a compatibility mismatch between TensorFlow, CUDA, and often cuDNN.

The key point is that GPU TensorFlow binaries are version-coupled. Installing "a CUDA version" is not enough; it must match the version expected by the TensorFlow package you installed.

Core Sections

1. Diagnose what TensorFlow expects and what system has

First, inspect TensorFlow version and GPU visibility.

bash
1python - <<'PY'
2import tensorflow as tf
3print(tf.__version__)
4print(tf.config.list_physical_devices('GPU'))
5PY

Then inspect available CUDA runtime libraries:

bash
ldconfig -p | grep libcudart
nvidia-smi

If only libcudart.so.11 or libcudart.so.12 exists while TensorFlow expects 7.5, that binary cannot load GPU runtime.

2. Fix by aligning versions (best option)

You usually have two paths:

  1. Install TensorFlow version compatible with your installed CUDA stack.
  2. Install the exact legacy CUDA stack expected by your TensorFlow build.

Modern environments should generally upgrade TensorFlow instead of installing very old CUDA 7.5.

bash
1python -m venv .venv
2source .venv/bin/activate
3pip install --upgrade pip
4pip install tensorflow

For legacy projects pinned to old TensorFlow, use container images matching historical dependencies to avoid host pollution.

bash
docker run --gpus all -it --rm tensorflow/tensorflow:latest-gpu python -c "import tensorflow as tf; print(tf.__version__)"

3. Ensure dynamic library paths are configured correctly

Even with correct versions installed, loader paths must include CUDA libs.

bash
export PATH=/usr/local/cuda/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH

Persist these in shell profile or service runtime environment. Then re-test:

bash
1python - <<'PY'
2import tensorflow as tf
3print('GPUs:', tf.config.list_physical_devices('GPU'))
4PY

Avoid symlink hacks like renaming one CUDA runtime version to another. They can cause subtle runtime crashes if ABI differs.

Common Pitfalls

  • Installing a random CUDA version without checking the TensorFlow package compatibility matrix.
  • Attempting to fix missing libcudart.so.7.5 by creating fake symlinks to newer runtimes.
  • Forgetting to update LD_LIBRARY_PATH in non-interactive environments (systemd, Docker entrypoints, CI).
  • Mixing multiple CUDA installations and accidentally loading the wrong library path first.
  • Ignoring cuDNN compatibility, which can fail later even after libcudart loads successfully.

Summary

This error is a version-alignment problem: TensorFlow expects libcudart.so.7.5, but your runtime environment does not provide it where the loader can find it. The robust fix is to align TensorFlow and CUDA/cuDNN versions, preferably using modern supported combinations or pinned containers for legacy stacks. Once versions and library paths are consistent, GPU initialization should work predictably.

For teams supporting multiple projects, isolate environments aggressively. Use separate virtual environments or containers per project and pin dependency versions in lock files. CUDA-related issues multiply when one machine hosts mixed legacy and modern ML stacks with shared environment variables. Isolation turns environment debugging from guesswork into reproducible setup.

It is also useful to automate preflight checks before training jobs start. A startup script can verify GPU driver visibility, required shared libraries, and TensorFlow import status. Failing fast with actionable diagnostics saves hours compared with discovering compatibility issues mid-training.

If immediate upgrades are impossible, document the exact legacy stack in a reproducible environment manifest and freeze it. Clear environment documentation reduces firefighting and enables safer long-term migration planning.

Teams that run legacy and modern models side by side should maintain separate base images and explicit compatibility matrices. This keeps upgrades controlled and avoids accidental dependency overlap that can break working workloads. Add CI checks that run a minimal GPU import test per image so failures are caught before deployment.


Course illustration
Course illustration

All Rights Reserved.