Skip to content

Commit fbd6a7a

Browse files
authored
Merge pull request #20647 from andriiryzhkov/ort_gpu
[AI] ORT library path preference and GPU acceleration UI
2 parents 3c8a77a + aef4da2 commit fbd6a7a

6 files changed

Lines changed: 644 additions & 61 deletions

File tree

data/darktableconfig.xml.in

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,13 @@
396396
<shortdescription>AI execution provider</shortdescription>
397397
<longdescription>select the hardware acceleration provider for AI inference. 'auto' will automatically detect the best available option for your system.</longdescription>
398398
</dtconfig>
399+
<dtconfig>
400+
<name>plugins/ai/ort_library_path</name>
401+
<type>string</type>
402+
<default></default>
403+
<shortdescription>custom ONNX Runtime library path</shortdescription>
404+
<longdescription>path to a custom ONNX Runtime shared library with GPU support (e.g. CUDA, MIGraphX, OpenVINO). when empty, darktable uses its bundled CPU-only library. set this to enable GPU acceleration without rebuilding.</longdescription>
405+
</dtconfig>
399406
<dtconfig>
400407
<name>plugins/ai/repository</name>
401408
<type>string</type>

src/ai/CMakeLists.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,13 @@ if(UNIX AND NOT APPLE)
4040
# before darktable has a chance to check the AI-enabled preference.
4141
# Also suppresses harmless "already registered" ONNX schema warnings
4242
# from system packages that link against libonnx.
43+
# Use just the filename (not the full build-tree path) so g_module_open
44+
# resolves it via LD_LIBRARY_PATH / system linker search. This is required
45+
# for AppImage where the build-tree path does not exist at runtime.
46+
get_filename_component(_ORT_LIB_NAME "${ONNXRuntime_LIBRARIES}" NAME)
4347
target_compile_definitions(darktable_ai PRIVATE
4448
ORT_LAZY_LOAD=1
45-
ORT_LIBRARY_PATH="${ONNXRuntime_LIBRARIES}")
49+
ORT_LIBRARY_PATH="${_ORT_LIB_NAME}")
4650
target_include_directories(darktable_ai PRIVATE ${ONNXRuntime_INCLUDE_DIRS})
4751
else()
4852
target_link_libraries(darktable_ai PUBLIC onnxruntime::onnxruntime)

src/ai/backend.h

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#pragma once
2020

2121
#include <stdint.h>
22+
#include <glib.h>
2223

2324
/**
2425
* @brief AI Execution Provider
@@ -63,6 +64,31 @@ dt_ai_provider_t dt_ai_provider_from_string(const char *str);
6364
* @return 1 if available, 0 if not. */
6465
int dt_ai_probe_provider(dt_ai_provider_t provider);
6566

67+
/** Probe a shared library to check if it's a valid ONNX Runtime build.
68+
* @return version string (caller must g_free) or NULL on failure. */
69+
char *dt_ai_ort_probe_library(const char *path);
70+
71+
/** Probe a library and return version + supported execution providers.
72+
* @param out_version version string (caller must g_free), may be NULL
73+
* @param out_eps comma-separated EP names (caller must g_free), may be NULL
74+
* @return 1 if valid ORT library, 0 otherwise */
75+
int dt_ai_ort_probe_library_full(const char *path, char **out_version, char **out_eps);
76+
77+
/** Result from dt_ai_ort_find_libraries(). Caller owns all strings. */
78+
typedef struct dt_ai_ort_found_t
79+
{
80+
char *path; // full path to the library
81+
char *version; // ORT version string
82+
char *eps; // comma-separated execution provider names
83+
} dt_ai_ort_found_t;
84+
85+
/** Scan system and user-space paths for valid ORT libraries.
86+
* @return GList of dt_ai_ort_found_t (caller must free with dt_ai_ort_found_free) */
87+
GList *dt_ai_ort_find_libraries(void);
88+
89+
/** Free a dt_ai_ort_found_t */
90+
void dt_ai_ort_found_free(dt_ai_ort_found_t *f);
91+
6692
/**
6793
* @brief Graph Optimization Level
6894
*

0 commit comments

Comments
 (0)