mirror of
https://github.com/typesense/typesense.git
synced 2025-05-20 21:52:23 +08:00
Check ONNX CUDA shared library before loading
This commit is contained in:
parent
088929d12f
commit
c9259731c8
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user