OSError: libcudart.so.11.0: cannot open shared object file: No such file or directory
Fixes OSError: libcudart.so.11.0: cannot open shared object file: No such file or directory Use when `import torch` (or torchvision/torch_geometric) fails with `libcudart.so.X` / `libcudnn` / `libtorch_cuda` not found on Linux Not for: Windows DLL errors or `No module named 'torch'`
How to fix OSError: libcudart.so.11.0: cannot open shared object file: No such file or directory
Your torch build wants CUDA 11.0 but the loader cannot find its libraries. Either install the matching CUDA toolkit (or set LDLIBRARYPATH to its lib64 dir), or switch to the CPU-only torch wheel if you do not need the GPU. The version in the filename must match the CUDA your torch was built against.
The exact error
OSError: libcudart.so.11.0: cannot open shared object file: No such file or directoryFix it
- Check what CUDA your torch expects: look at the +cuXX tag in
python -m pip show torch.
Expected: e.g. cu110, cu118, cu121
- Option A (keep GPU): install that CUDA toolkit, or point the loader at it:
export LD_LIBRARY_PATH=/usr/local/cuda-11.0/lib64:$LD_LIBRARY_PATH.
Expected: import torch no longer raises the OSError
- Option B (no GPU needed):
pip install torch --index-url https://download.pytorch.org/whl/cpu.
Expected: torch imports and runs on CPU
When this applies
import torch (or torchvision/torchgeometric) fails with libcudart.so.X / libcudnn / `libtorchcuda` not found on Linux
When this does NOT apply
Windows DLL errors or No module named 'torch'
Versions
Linux, CUDA builds of torch
Why it happens
CUDA torch wheels still resolve some CUDA libs from the system; a version mismatch or missing toolkit breaks the load.
Edge cases
nvidia-smi showing CUDA 12.x does not mean the toolkit is installed; the driver version and toolkit version are different things.
Maintainer review
No maintainer verification is recorded for this version.
This records the version a maintainer checked. It does not assert that the version is the latest upstream release.