Skip to content

Open Source alternative to Algolia + Pinecone and an Easier-to-Use alternative to ElasticSearch ⚡ 🔍 ✨ Fast, typo tolerant, in-memory fuzzy Search Engine for building delightful search experiences

Check ONNX CUDA shared library before loading

ozanarmaganc9259731c8fc
diff --git a/src/text_embedder.cpp b/src/text_embedder.cpp
index cf4a7c47..080a2cfb 100644
--- a/src/text_embedder.cpp
+++ b/src/text_embedder.cpp
@@ -5,6 +5,7 @@
#include <fstream>
#include <sstream>
#include <filesystem>
+#include <dlfcn.h>
TextEmbedder::TextEmbedder(const std::string& model_name) {
// create environment
@@ -12,6 +13,14 @@ TextEmbedder::TextEmbedder(const std::string& model_name) {
auto providers = Ort::GetAvailableProviders();
for(auto& provider : providers) {
if(provider == "CUDAExecutionProvider") {
+
+ // check existence of so file
+ void* handle = dlopen("libonnxruntime_providers_cuda.so", RTLD_NOW | RTLD_GLOBAL);
+ if(!handle) {
+ LOG(ERROR) << "Cannot load libonnxruntime_providers_cuda.so";
+ continue;
+ }
+
LOG(INFO) << "Using CUDAExecutionProvider";
OrtCUDAProviderOptions cuda_options;
session_options.AppendExecutionProvider_CUDA(cuda_options);