GPU acceleration for AI features in Darktable - help needed testing install scripts

Thanks, Anry, got it to work. Please excuse my late comprehension.

$ ./install-ort-gpu.sh --manifest ort_gpu.json
ONNX Runtime 1.24.4 - GPU acceleration installer
============================================================

GPU: NVIDIA GeForce GTX 1080
Driver: 535.288.01
ORT version: 1.24.4
Download size: ~200 MB
Install to: /home/markus/.local/lib/onnxruntime-cuda
Requirements: CUDA 12.x, cuDNN 9.x

Continue? [y/N] y

Downloading...
/tmp/tmp.3pnVUvHPFT/ort-package        100%[============================================================================>] 195.91M  2.39MB/s    in 79s     
Verifying checksum...
Checksum OK.
Extracting...

Done. Installed to: /home/markus/.local/lib/onnxruntime-cuda
-rwxr-xr-x 1 markus markus 302M Apr  8 13:41 /home/markus/.local/lib/onnxruntime-cuda/libonnxruntime_providers_cuda.so
-rwxr-xr-x 1 markus markus  15K Apr  8 13:41 /home/markus/.local/lib/onnxruntime-cuda/libonnxruntime_providers_shared.so
-rwxr-xr-x 1 markus markus 835K Apr  8 13:41 /home/markus/.local/lib/onnxruntime-cuda/libonnxruntime_providers_tensorrt.so
-rwxr-xr-x 1 markus markus  25M Apr  8 13:41 /home/markus/.local/lib/onnxruntime-cuda/libonnxruntime.so.1.24.4

To enable in darktable:

  1. Open darktable preferences (Ctrl+,)
  2. Go to the AI tab
  3. Click 'detect' to find the installed library automatically,
     or set 'ONNX Runtime library' to:
 /home/markus/.local/lib/onnxruntime-cuda/libonnxruntime.so.1.24.4
  4. Restart darktable

So far the script did work well on my Ubuntu 2024.04. But darktable is not working with the GPU.

86.2033 [darktable_ai] dt_ai_env_init start.
86.2037 [darktable_ai] discovered: upscale bsrgan (upscale-bsrgan, backend=onnx)
86.2038 [darktable_ai] discovered: mask segnext vitb-sax2 hq (mask-object-segnext-b2hq, backend=onnx)
86.2039 [darktable_ai] discovered: mask sam2.1 hiera small (mask-object-sam21-small, backend=onnx)
86.2040 [darktable_ai] discovered: denoise nind (denoise-nind, backend=onnx)
86.2116 [darktable_ai] loaded ORT 1.24.4 from '/home/markus/.local/lib/onnxruntime-cuda/libonnxruntime.so.1.24.4'
86.2116 [darktable_ai] execution provider: auto
86.2367 [darktable_ai] loading: /home/markus/.local/share/darktable/models/mask-object-sam21-small/encoder.onnx
86.2368 [darktable_ai] attempting to enable NVIDIA CUDA...
2026-04-08 14:21:21.716323146 [E:onnxruntime:DarktableAI, provider_bridge_ort.cc:2101 Create] /onnxruntime_src/onnxruntime/core/session/provider_bridge_ort.cc:1952 onnxruntime::Provider& onnxruntime::ProviderLibrary::Get() [ONNXRuntimeError] : 1 : FAIL : Failed to load library /home/markus/.local/lib/onnxruntime-cuda/libonnxruntime_providers_cuda.so with error: libcudnn.so.9: cannot open shared object file: No such file or directory

86.2383 [darktable_ai] NVIDIA CUDA enable failed: OrtSessionOptionsAppendExecutionProvider_Cuda: Failed to load shared library
86.2383 [darktable_ai] attempting to enable AMD MIGraphX...
86.2383 [darktable_ai] AMD MIGraphX provider not found.
86.2383 [darktable_ai] attempting to enable AMD ROCm (legacy)...
86.2383 [darktable_ai] AMD ROCm (legacy) provider not found.
86.9093 [darktable_ai] loading: /home/markus/.local/share/darktable/models/mask-object-sam21-small/decoder.onnx
86.9093 [darktable_ai] using CPU only (no hardware acceleration)

After installing libcudnn-frontend-dev I get the required libcudnn.so, but it seems to be of an older version. I get the same error as above.

$ ls -l /usr/lib/x86_64-linux-gnu/libcudnn.so*
lrwxrwxrwx 1 25503 2174     13 Mai 31  2023 /usr/lib/x86_64-linux-gnu/libcudnn.so -> libcudnn.so.8
lrwxrwxrwx 1 25503 2174     17 Mai 31  2023 /usr/lib/x86_64-linux-gnu/libcudnn.so.8 -> libcudnn.so.8.9.2
-rw-r--r-- 1 root  root 150200 Apr  8 14:38 /usr/lib/x86_64-linux-gnu/libcudnn.so.8.9.2

It looks like libcudnn.so.9 is not available in the Ubuntu 2024.04 repositories.

I’d recommend using NVidia package repositories:

wget https://developer.download.nvidia.com/compute/cudnn/9.20.0/local_installers/cudnn-local-repo-ubuntu2404-9.20.0_1.0-1_amd64.deb
sudo dpkg -i cudnn-local-repo-ubuntu2404-9.20.0_1.0-1_amd64.deb
sudo cp /var/cudnn-local-repo-ubuntu2404-9.20.0/cudnn-*-keyring.gpg /usr/share/keyrings/
sudo apt-get update
sudo apt-get -y install cudnn

More details on it here cuDNN 9.20.0 Downloads | NVIDIA Developer

Thanks Andrii,

I had some trouble uninstalling the old cuDNN package. I got the error:

Unpacking libcudnn9-dev-cuda-13 (9.20.0.48-1) ...
dpkg: error processing archive /tmp/apt-dpkg-install-O3Dr1M/2-libcudnn9-dev-cuda-13_9.20.0.48-1_amd64.deb (--unpack):
trying to overwrite '/usr/lib/x86_64-linux-gnu/libcudnn.so', which is also in package nvidia-cudnn 8.9.2.26~cuda12+3

After uninstalling with dpkg -r --force-all cudnn, installing the Nividia package worked.

Now my installed packages look liks this:

$ dpkg -l | grep cud
ii  cudnn                                            9.20.0-1                                      amd64        NVIDIA CUDA Deep Neural Network library (cuDNN)
ii  cudnn-local-repo-ubuntu2404-9.20.0               1.0-1                                         amd64        cudnn-local repository configuration files
ii  cudnn9                                           9.20.0-1                                      amd64        NVIDIA CUDA Deep Neural Network library (cuDNN)
ii  cudnn9-cuda-13                                   9.20.0.48-1                                   amd64        NVIDIA cuDNN for CUDA 13
ii  cudnn9-cuda-13-2                                 9.20.0.48-1                                   amd64        NVIDIA cuDNN for CUDA 13.2
ii  libcudart12:amd64                                12.0.146~12.0.1-4build4                       amd64        NVIDIA CUDA Runtime Library
ii  libcudnn9-cuda-13                                9.20.0.48-1                                   amd64        cuDNN runtime libraries for CUDA 13.2
ii  libcudnn9-dev-cuda-13                            9.20.0.48-1                                   amd64        cuDNN development libraries for CUDA 13.2
ii  libcudnn9-headers-cuda-13                        9.20.0.48-1                                   amd64        cuDNN header files for CUDA 13.2
ii  libcudnn9-samples                                9.20.0.48-1                                   all          cuDNN samples
ii  libcudnn9-static-cuda-13                         9.20.0.48-1                                   amd64        cuDNN static libraries for CUDA 13.2
ii  nvidia-cuda-dev:amd64                            12.0.146~12.0.1-4build4                       amd64        NVIDIA CUDA development files
ii  nvidia-cuda-gdb                                  12.0.140~12.0.1-4build4                       amd64        NVIDIA CUDA Debugger (GDB)
ii  nvidia-cuda-toolkit                              12.0.140~12.0.1-4build4                       amd64        NVIDIA CUDA development toolkit
ii  nvidia-cuda-toolkit-doc                          12.0.1-4build4                                all          NVIDIA CUDA and OpenCL documentation
ii  nvidia-cuda-toolkit-gcc                          12.0.1-4build4                                amd64        NVIDIA CUDA development toolkit (GCC compatibility)
rc  nvidia-cudnn                                     8.9.2.26~cuda12+3                             amd64        NVIDIA CUDA Deep Neural Network library (install script)

But now darktable throws an exception when I attempt to use the GPU:

30.6875 [darktable_ai] dt_ai_env_init start.
30.6877 [darktable_ai] discovered: upscale bsrgan (upscale-bsrgan, backend=onnx)
30.6878 [darktable_ai] discovered: mask segnext vitb-sax2 hq (mask-object-segnext-b2hq, backend=onnx)
30.6878 [darktable_ai] discovered: mask sam2.1 hiera small (mask-object-sam21-small, backend=onnx)
30.6879 [darktable_ai] discovered: denoise nind (denoise-nind, backend=onnx)
30.6977 [darktable_ai] loaded ORT 1.24.4 from '/home/markus/.local/lib/onnxruntime-cuda/libonnxruntime.so.1.24.4'
30.6977 [darktable_ai] execution provider: auto
30.7391 [darktable_ai] loading: /home/markus/.local/share/darktable/models/mask-object-sam21-small/encoder.onnx
30.7393 [darktable_ai] attempting to enable NVIDIA CUDA...
31.0939 [darktable_ai] NVIDIA CUDA enabled successfully.
2026-04-08 20:25:38.935037835 [E:onnxruntime:, inference_session.cc:2619 operator()] Exception during initialization: /onnxruntime_src/onnxruntime/core/providers/cuda/cuda_call.cc:129 std::conditional_t<THRW, void, onnxruntime::common::Status> onnxruntime::CudaCall(ERRTYPE, const char*, const char*, SUCCTYPE, const char*, const char*, int) [with ERRTYPE = cudnnStatus_t; bool THRW = true; SUCCTYPE = cudnnStatus_t; std::conditional_t<THRW, void, common::Status> = void] /onnxruntime_src/onnxruntime/core/providers/cuda/cuda_call.cc:121 std::conditional_t<THRW, void, onnxruntime::common::Status> onnxruntime::CudaCall(ERRTYPE, const char*, const char*, SUCCTYPE, const char*, const char*, int) [with ERRTYPE = cudnnStatus_t; bool THRW = true; SUCCTYPE = cudnnStatus_t; std::conditional_t<THRW, void, common::Status> = void] CUDNN failure 1001: CUDNN_STATUS_NOT_INITIALIZED ; GPU=0 ; hostname=altair ; file=/onnxruntime_src/onnxruntime/core/providers/cuda/cuda_execution_provider.cc ; line=232 ; expr=cudnnCreate(&cudnn_handle_); 
31.7922 [darktable_ai] session failed: Exception during initialization: /onnxruntime_src/onnxruntime/core/providers/cuda/cuda_call.cc:129 std::conditional_t<THRW, void, onnxruntime::common::Status> onnxruntime::CudaCall(ERRTYPE, const char*, const char*, SUCCTYPE, const char*, const char*, int) [with ERRTYPE = cudnnStatus_t; bool THRW = true; SUCCTYPE = cudnnStatus_t; std::conditional_t<THRW, void, common::Status> = void] /onnxruntime_src/onnxruntime/core/providers/cuda/cuda_call.cc:121 std::conditional_t<THRW, void, onnxruntime::common::Status> onnxruntime::CudaCall(ERRTYPE, const char*, const char*, SUCCTYPE, const char*, const char*, int) [with ERRTYPE = cudnnStatus_t; bool THRW = true; SUCCTYPE = cudnnStatus_t; std::conditional_t<THRW, void, common::Status> = void] CUDNN failure 1001: CUDNN_STATUS_NOT_INITIALIZED ; GPU=0 ; hostname=altair ; file=/onnxruntime_src/onnxruntime/core/providers/cuda/cuda_execution_provider.cc ; line=232 ; expr=cudnnCreate(&cudnn_handle_); 
- retrying with provider + basic opt
31.7923 [darktable_ai] attempting to enable NVIDIA CUDA...
31.7923 [darktable_ai] NVIDIA CUDA enabled successfully.
2026-04-08 20:25:39.315080199 [E:onnxruntime:, inference_session.cc:2619 operator()] Exception during initialization: /onnxruntime_src/onnxruntime/core/providers/cuda/cuda_call.cc:129 std::conditional_t<THRW, void, onnxruntime::common::Status> onnxruntime::CudaCall(ERRTYPE, const char*, const char*, SUCCTYPE, const char*, const char*, int) [with ERRTYPE = cudnnStatus_t; bool THRW = true; SUCCTYPE = cudnnStatus_t; std::conditional_t<THRW, void, common::Status> = void] /onnxruntime_src/onnxruntime/core/providers/cuda/cuda_call.cc:121 std::conditional_t<THRW, void, onnxruntime::common::Status> onnxruntime::CudaCall(ERRTYPE, const char*, const char*, SUCCTYPE, const char*, const char*, int) [with ERRTYPE = cudnnStatus_t; bool THRW = true; SUCCTYPE = cudnnStatus_t; std::conditional_t<THRW, void, common::Status> = void] CUDNN failure 1001: CUDNN_STATUS_NOT_INITIALIZED ; GPU=0 ; hostname=altair ; file=/onnxruntime_src/onnxruntime/core/providers/cuda/cuda_execution_provider.cc ; line=232 ; expr=cudnnCreate(&cudnn_handle_); 
32.1705 [darktable_ai] session failed: Exception during initialization: /onnxruntime_src/onnxruntime/core/providers/cuda/cuda_call.cc:129 std::conditional_t<THRW, void, onnxruntime::common::Status> onnxruntime::CudaCall(ERRTYPE, const char*, const char*, SUCCTYPE, const char*, const char*, int) [with ERRTYPE = cudnnStatus_t; bool THRW = true; SUCCTYPE = cudnnStatus_t; std::conditional_t<THRW, void, common::Status> = void] /onnxruntime_src/onnxruntime/core/providers/cuda/cuda_call.cc:121 std::conditional_t<THRW, void, onnxruntime::common::Status> onnxruntime::CudaCall(ERRTYPE, const char*, const char*, SUCCTYPE, const char*, const char*, int) [with ERRTYPE = cudnnStatus_t; bool THRW = true; SUCCTYPE = cudnnStatus_t; std::conditional_t<THRW, void, common::Status> = void] CUDNN failure 1001: CUDNN_STATUS_NOT_INITIALIZED ; GPU=0 ; hostname=altair ; file=/onnxruntime_src/onnxruntime/core/providers/cuda/cuda_execution_provider.cc ; line=232 ; expr=cudnnCreate(&cudnn_handle_); 
- retrying with CPU + full opt
32.6861 [darktable_ai] loading: /home/markus/.local/share/darktable/models/mask-object-sam21-small/decoder.onnx
32.6861 [darktable_ai] using CPU only (no hardware acceleration)

I’m sorry for the trouble, but this looks like a real pain to get working. Oh, well bleeding edge…

Which version of CUDA Toolkit do you have? 12 or 13?
I see in your logs cuDNN for CUDA 13.

Looks like I have version 12.

markus@altair:~/Workbench/darktable$ nvcc --version
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2023 NVIDIA Corporation
Built on Fri_Jan__6_16:45:21_PST_2023
Cuda compilation tools, release 12.0, V12.0.140
Build cuda_12.0.r12.0/compiler.32267302_0
markus@altair:~/Workbench/darktable$ nvidia-smi
Wed Apr  8 21:00:32 2026       
+---------------------------------------------------------------------------------------+
| NVIDIA-SMI 535.288.01             Driver Version: 535.288.01   CUDA Version: 12.2     |
|-----------------------------------------+----------------------+----------------------+
| GPU  Name                 Persistence-M | Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp   Perf          Pwr:Usage/Cap |         Memory-Usage | GPU-Util  Compute M. |
|                                         |                      |               MIG M. |
|=========================================+======================+======================|
|   0  NVIDIA GeForce GTX 1080        Off | 00000000:26:00.0  On |                  N/A |
|  0%   61C    P0              50W / 210W |    696MiB /  8192MiB |      2%      Default |
|                                         |                      |                  N/A |
+-----------------------------------------+----------------------+----------------------+

I’ve now purged the CUDA Toolkit version 12 on my system and installed version 13.

But now I get the following error:

23.2894 [darktable_ai] attempting to enable NVIDIA CUDA...
2026-04-08 22:18:59.825197008 [E:onnxruntime:DarktableAI, provider_bridge_ort.cc:2101 Create] /onnxruntime_src/onnxruntime/core/session/provider_bridge_ort.cc:1952 onnxruntime::Provider& onnxruntime::ProviderLibrary::Get() [ONNXRuntimeError] : 1 : FAIL : Failed to load library /home/markus/.local/lib/onnxruntime-cuda/libonnxruntime_providers_cuda.so with error: libcublasLt.so.12: cannot open shared object file: No such file or directory

It looks like darktable is actually looking for version 12.

I had the same issue. Apparently, it works only with version 12.
(see above).
I guess you have to remove version 13 including cuDNN and install both again with version 12.

I went back to version 12. Now darktable seems to find the driver, but fails to use it, same as above:

21.8705 [darktable_ai] session failed: /onnxruntime_src/onnxruntime/core/providers/cuda/cuda_call.cc:129 std::conditional_t<THRW, void, onnxruntime::common::Status> onnxruntime::CudaCall(ERRTYPE, const char*, const char*, SUCCTYPE, const char*, const char*, int) [with ERRTYPE = cudaError; bool THRW = true; SUCCTYPE = cudaError; std::conditional_t<THRW, void, common::Status> = void] /onnxruntime_src/onnxruntime/core/providers/cuda/cuda_call.cc:121 std::conditional_t<THRW, void, onnxruntime::common::Status> onnxruntime::CudaCall(ERRTYPE, const char*, const char*, SUCCTYPE, const char*, const char*, int) [with ERRTYPE = cudaError; bool THRW = true; SUCCTYPE = cudaError; std::conditional_t<THRW, void, common::Status> = void] CUDA failure 35: CUDA driver version is insufficient for CUDA runtime version ; GPU=-1 ; hostname=altair ; file=/onnxruntime_src/onnxruntime/core/providers/cuda/cuda_execution_provider.cc ; line=334 ; expr=cudaSetDevice(info_.device_id); 

I’m a bit lost how to proceed…

CUDA Runtime 13 is also supported by ONNX Runtime. But it is specific to the CUDA version, meaning the same ONNX Runtime build will not work on both CUDA Runtime 12 and 13.

My recommendation is to update GPU installation script and run it once again. It will detect CUDA 13 and install correct version of ONNX Runtime.

Similar situation (or even a bit more complicated) is with AMD GPUs, where specific version of ROCm is supported only by one mapped version of ONNX Runtime.

Install scripts handle all of this complexity. You just need to rerun it after hardware or toolkits chages.

I see the error CUDA driver version is insufficient for CUDA runtime version in the log. That means CUDA Toolkit installation is broken. Maybe because you installed so many different versions, but not sure. I can not advise on this, apart from our documentation with dependancies description (it also contains links to the installation instructions from vendors).

1 Like

Thanks Andrii,

Originally I only had the toolkit from the Ubuntu repos installed. When I saw your message asking about my toolkit version I assumed that I did need version 13 and installed it from the Nvidia source. I did not re-run your install script, though.

But I did uninstall version 13 completely, before re-installing version 12.

I think it would be useful, if your script can run some checks to verify that an usable driver is installed.

I’m travelling right now and will try to clean out the v12 driver and install it again by tomorrow.

I’ve removed all NVidia stuff (apt purge) and re-added it again. Then I ran ‘./install-ort-gpu.sh’. I had to specify the manifest location, although it was in the same directory as the script. It did not detect the graphics card, but specifying “nvidia” did the trick, and now Darktable uses ‘NVIDIA CUDA’ for ai !

Later I found that my purge also removed the graphics driver. After reinstalling it, the script did detect the graphics card again.

An interesting but cumbersome experience. Lots of moving parts !

Thanks for your help!

I am glad you have positive result. Yes, dealing with GPU drivers and acceleration libraries, which are external to Darktable, is a bit tedious. Unfortunately, there’s no default easy way to enable GPU acceleration in Linux. On Windows and macOS it is easier.

But once you have it, it pays off with excellent performance on CUDA.

Yes, especially the image analysis is quite a bit faster with CUDA. But for the mask creation task, I can live with the couple of seconds’ wait on the CPU. This will be much more important for denoising.

But I find it very encouraging that ai is taken up by you devs. This is the only area where I feel that Lightroon currently has a headstart.

1 Like