terminate called after throwing an instance of 'Ort::Exception'
what(): /onnxruntime_src/onnxruntime/core/session/provider_bridge_ort.cc:1193 onnxruntime::Provider& onnxruntime::ProviderLibrary::Get() [ONNXRuntimeError] : 1 : FAIL : Failed to load library libonnxruntime_providers_cuda.so with error: libcudnn.so.8: cannot open shared object file: No such file or directory
Signal: SIGABRT (Aborted)
在 CMakeLists.txt 中,我添加了此 lib abs 路径,并且确保此 lib 路径存在
file(GLOB cuda_libs /usr/local/cuda-11.8/lib64/*.so*)
file(GLOB cudnn_libs /home/roroco/Downloads/cpp-lib/cudnn-linux-x86_64-8.9.0.131_cuda11-archive/lib/*.so.*)
file(GLOB onnx_libs /home/roroco/Downloads/cpp-lib/onnxruntime-linux-x64-gpu-1.16.3/lib/*.so.*)
file(GLOB cv_libs /home/roroco/Downloads/cpp-lib/opencv-4.9.0/dist/lib/*.so.*)
set(libs
${cuda_libs}
${cudnn_libs}
${onnx_libs}
${cv_libs}
/home/roroco/Downloads/cpp-lib/cudnn-linux-x86_64-8.9.0.131_cuda11-archive/lib/libcudnn.so.8
)
message("libs:${libs}")
list(REMOVE_DUPLICATES libs)
# Link the libraries to your executable
target_link_libraries(inference ${libs})
如何解决
就我而言,我的 /usr/local 不包含 cudnn,我应该将 cudnn lib dir 添加到 LD_LIBRARY_PATH
LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/home/roroco/Downloads/cpp-lib/cudnn-linux-x86_64-8.9.0.131_cuda11-archive/lib cpp_cmd
在 clion debug conf 中,我可以设置 env var
我认为简单的方法是将
export LD_LIBRARY_PATH=$LIBRARY_PATH:path/to/cudnn/lib/dir
放在 ~/.bashrc 中以在所有 cmd 启动时设置 cudnn lib 目录