Fix ImportError: libcublas.so.9.0 cannot open shared object file
Quick answer
This error means the dynamic loader can't find libcublas.so.9.0 — the CUDA 9.0 cuBLAS library your TensorFlow (or PyTorch) build was compiled against. The version suffix must match exactly. Run `ldconfig -p | grep libcublas`: if it lists the file, add its directory to LD_LIBRARY_PATH; if it lists nothing, install the matching CUDA 9.0 toolkit, or switch to a framework build that matches the CUDA you actually have.
ImportError: libcublas.so.9.0: cannot open shared object file: No such file or directory is a dynamic-linking failure. When your framework (usually TensorFlow-GPU, sometimes PyTorch) loads, the OS linker tries to open the exact CUDA library it was built against — libcublas.so.9.0 — and can't find it on the search path. The same pattern covers libcudart.so.11.0, libcudnn.so.7, libcufft.so.10, and every other lib*.so.<version> CUDA error: same cause, same fix.
Why the version suffix matters
That .9.0 is a SONAME — the exact major.minor the binary was compiled to link. cuBLAS from CUDA 9.0 is libcublas.so.9.0; from CUDA 11 it's libcublas.so.11. They are different files, and the loader will not accept one for the other. So "I have CUDA installed" isn't enough — you need the specific version your framework build expects. A request for libcublas.so.9.0 means something on your machine (a TensorFlow build for CUDA 9.0) needs CUDA 9.0, and 9.0 either isn't installed or isn't on the path.
Triage in one command
ldconfig -p | grep libcublas- It prints a path → the library exists; this is a path problem. The loader just doesn't know where it is.
- It prints nothing → the library isn't installed. This is a missing-toolkit problem.
Confirm what versions you actually have:
nvidia-smi # driver + the MAX CUDA it supports
nvcc --version # the installed CUDA TOOLKIT version
find / -name 'libcublas.so*' 2>/dev/null # where any cuBLAS livesRemember: nvidia-smi's CUDA number is the driver's ceiling, not the installed toolkit. The framework needs the toolkit libraries present.
Fix 1 — path problem: point the loader at the library
If libcublas.so.9.0 exists (say under /usr/local/cuda-9.0/lib64) but isn't found, add its directory to the loader path:
export LD_LIBRARY_PATH=/usr/local/cuda-9.0/lib64:$LD_LIBRARY_PATH
sudo ldconfig # refresh the loader cachePersist it by adding a file under /etc/ld.so.conf.d/ (then sudo ldconfig) or exporting LD_LIBRARY_PATH in your shell profile / service env.
Fix 2 — missing toolkit: install the matching CUDA
If it isn't installed, install the CUDA version your framework wants (9.0 here), plus the matching cuDNN. The versions must line up with the framework's compatibility matrix — each TensorFlow release targets a specific CUDA + cuDNN pair. Installing CUDA 11 will not satisfy a libcublas.so.9.0 request.
Fix 3 — the clean way: let a tool match the stack
Hand-managing CUDA .so files is where hours disappear. Two approaches remove the problem:
# conda pulls a compatible cudatoolkit + cudnn automatically
conda install -c conda-forge tensorflow-gpu=1.12
# or run the official GPU image; only the host NVIDIA driver is needed
docker run --gpus all -it tensorflow/tensorflow:2.15.0-gpu bashBoth give you a framework whose CUDA libraries are guaranteed to match.
Fix 4 — or move the framework to your CUDA
If you're stuck on a specific CUDA version, install a framework build compiled for it instead. Matching either direction works — the point is that the framework's expected CUDA and the installed CUDA must be the same major.minor.
Prevent it
- Match versions deliberately using the framework's CUDA/cuDNN compatibility table before installing.
- Prefer conda or Docker so the GPU stack is resolved for you.
- Keep driver and toolkit straight: the driver sets the ceiling; the toolkit provides the libraries the framework links.
- Pin everything in a reproducible environment file so the matched stack doesn't drift.
Decide whether it's a path or a missing-library problem with one ldconfig command, then either expose the existing library or install the exact CUDA version your framework was built against.
Sources
Key takeaways
- •The `.9.0` suffix is not cosmetic — the framework needs that exact CUDA major.minor. A 10.x or 11.x install will not satisfy a request for libcublas.so.9.0.
- •First triage: `ldconfig -p | grep libcublas`. Output = a path problem (LD_LIBRARY_PATH). No output = the library isn't installed.
- •The root cause is a version mismatch: your framework build expects one CUDA version and a different one (or none) is installed.
- •The clean fix is to match the stack — use conda or the official GPU Docker image so CUDA/cuDNN come matched to the framework automatically.
- •`nvidia-smi` shows the driver's max supported CUDA; `nvcc --version` shows the installed toolkit. The framework needs the toolkit version, not just a new-enough driver.
Frequently asked questions
I have CUDA 11 installed — why does it still ask for libcublas.so.9.0?
Because your framework build was compiled against CUDA 9.0 and links the library by its exact SONAME, libcublas.so.9.0. CUDA 11 ships libcublas.so.11, which is a different file the loader won't accept as a substitute. Either install CUDA 9.0 alongside, or use a framework build compiled for CUDA 11.
How do I tell if it's a PATH problem or a missing library?
Run `ldconfig -p | grep libcublas` and `find / -name 'libcublas.so*' 2>/dev/null`. If the file exists somewhere but isn't on the loader path, add its directory to LD_LIBRARY_PATH. If it doesn't exist at all, you need to install the matching CUDA toolkit.
What's the least painful way to avoid CUDA library hell entirely?
Let a package manager match the stack for you. `conda install tensorflow-gpu=<version>` pulls a compatible cudatoolkit and cuDNN automatically, and the official TensorFlow/PyTorch GPU Docker images bundle everything except the host driver. Both avoid hand-managing .so files.
Does a newer NVIDIA driver fix this?
Not by itself. A newer driver raises the maximum CUDA version you can run (nvidia-smi shows it), but the framework needs the specific CUDA toolkit libraries it was built against to be present. Driver and toolkit are separate things.
Software Engineering Leader & Technical Author · Updated August 31, 2026