onnxruntime: FAIL : Failed to load library libonnxruntime_providers_cuda.so with error: libcublasLt.so.11: cannot open shared object file: No such file or directory

Describe the issue

when i inference with optimum.onnxruntime,an error occurred:

FAIL : Failed to load library libonnxruntime_providers_cuda.so with error: libcublasLt.so.11: cannot open shared object file: No such file or directory 652ee3ba21bc03c88c2fabd03ca5393

my env is as follow: cuda 12.1 cudnn8 onnxruntime-gpu 1.16

and I found this doc(https://onnxruntime.ai/docs/execution-providers/CUDA-ExecutionProvider.html): image

so I tried to update onnxruntime-gpu to 1.18.0, but the same error still occurred.

But when I updated the version of onnxruntime-gpu to 1.18.1, another error occurred, as follows: FAIL : Failed to load library libonnxruntime_providers_cuda.so with error: libcudnn.so.9: cannot open shared object file: No such file or directory cb85e4b2f35f9e91bd6dbb55e7eabb4

so, with cuda12.1 and cudnn8, which version of onnxruntime-gpu should i install?

To reproduce

pass

Urgency

not

Platform

Linux

OS Version

ubuntu 20.04.6 LTS

ONNX Runtime Installation

Released Package

ONNX Runtime Version or Commit ID

onnxruntime-gpu 1.18.0

ONNX Runtime API

Python

Architecture

X64

Execution Provider

CUDA

Execution Provider Library Version

cuda 12.1

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 2
  • Comments: 16 (3 by maintainers)

Most upvoted comments

For CUDA and cuDNN version, you can look up here: https://onnxruntime.ai/docs/execution-providers/CUDA-ExecutionProvider.html#requirements

Then you can install according to this: https://onnxruntime.ai/docs/install/#install-onnx-runtime-ort-1

Summary of recommended combinations:

CUDA cuDNN PyTorch onnxruntime-gpu Install command
12.x 9.x 2.4.1 1.19.2 pip install onnxruntime-gpu==1.19.2
12.x 8.9 2.3.1 1.18.0 pip install onnxruntime-gpu==1.18.0 --extra-index-url https://aiinfra.pkgs.visualstudio.com/PublicPackages/_packaging/onnxruntime-cuda-12/pypi/simple/
11.8 8.9 2.3.1 1.19.2 pip install onnxruntime-gpu==1.19.2 --extra-index-url https://aiinfra.pkgs.visualstudio.com/PublicPackages/_packaging/onnxruntime-cuda-11/pypi/simple/

I fixed it by just import torch before import onnxruntime:

import torch import onnxruntime

I am using

onnx                     1.16.2
onnxruntime-gpu          1.18.1

With cuda 12.x and cudnn 9.x, based on the provided version table, that would work. But I am stuck on this error requiring libcublasLt.so.11 wich does not exist in cuda 12.x instalation.

@andreclaudino, @eaven123 , you can pip install onnxruntime-gpu==1.19.0 to work with cuda 12.x and cudnn 9.x.

If you pip install onnxruntime-gpu==1.18.1, you need cuda 11.8 and cudnn 8.9.

https://onnxruntime.ai/docs/execution-providers/CUDA-ExecutionProvider.html#cuda-12x

ONNX Runtime CUDA cuDNN
1.18.1 12.x 9.x
1.18.0 12.x 8.x

From the above table, 1.18.0 is good for cuda 12.x and cudnn 8.x.

You can install like

pip install onnxruntime-gpu==1.18.0 --extra-index-url https://aiinfra.pkgs.visualstudio.com/PublicPackages/_packaging/onnxruntime-cuda-12/pypi/simple/ --force-reinstall

See https://onnxruntime.ai/docs/install/#install-onnx-runtime-gpu-cuda-12x for installation.

I solved it by using: pip install --no-cache-dir onnxruntime-gpu==1.17.1 --extra-index-url https://aiinfra.pkgs.visualstudio.com/PublicPackages/_packaging/onnxruntime-cuda-12/pypi/simple

I found this thread while trying to figure out why import torch would allow ORT to find start finding libraries, and looks like other people have the same issue, even if it wasn’t OP’s original problem.

A solution that let me avoid the torch import in my environment:

import onnxruntime as ort

ort.preload_dlls()

Context in the linked comment above; the previous comment in that thread was a helpful explanation of the underlying problem for me.

I fixed it by just import torch before import onnxruntime:

import torch import onnxruntime

Really, it’s the only thing that works. It’s crazy. I don’t want to pull the torch dependency and make this idiotic crutch, but that’s the only thing that makes this shit work. It’s kind of crazy. You can’t seem to handle your own software and dependency hell.