I am trying to make darktable opencl work with the nouveau driver on Arch Linux. I have installed opencl-rusticl-mesa and set the environment variable RUSTICL_ENABLE=nouveau. I also activated rusticl in darktable opencl settings. Now I get this when I type darktable-cltest:
[anna@archlinux ~]$ darktable-cltest
darktable 4.6.1
Copyright (C) 2012-2024 Johannes Hanika and other contributors.
Compile options:
Bit depth -> 64 bit
Debug -> DISABLED
SSE2 optimizations -> ENABLED
OpenMP -> ENABLED
OpenCL -> ENABLED
Lua -> ENABLED - API version 9.2.0
Colord -> ENABLED
gPhoto2 -> ENABLED
GMIC -> ENABLED - Compressed LUTs are supported
GraphicsMagick -> ENABLED
ImageMagick -> DISABLED
libavif -> ENABLED
libheif -> ENABLED
libjxl -> ENABLED
OpenJPEG -> ENABLED
OpenEXR -> ENABLED
WebP -> ENABLED
See https://www.darktable.org/resources/ for detailed documentation.
See https://github.com/darktable-org/darktable/issues/new/choose to report bugs.
0.0113 [dt_get_sysresource_level] switched to 1 as `default'
0.0113 total mem: 15915MB
0.0113 mipmap cache: 1989MB
0.0113 available mem: 7957MB
0.0113 singlebuff: 124MB
0.0151 [opencl_init] opencl disabled via darktable preferences
0.0152 [opencl_init] opencl library 'libOpenCL' found on your system and loaded, preference 'default path'
0.1253 [opencl_init] found 1 platform
[opencl_init] found 1 device
[dt_opencl_device_init]
DEVICE: 0: 'NV168'
PLATFORM, VENDOR & ID: rusticl, Mesa/X.org, ID=4318
CANONICAL NAME: rusticlnv168
DRIVER VERSION: 24.0.4-arch1.2
DEVICE VERSION: OpenCL 3.0 , SM_20 SUPPORT
DEVICE_TYPE: GPU, dedicated mem
GLOBAL MEM SIZE: 6134 MB
MAX MEM ALLOC: 2048 MB
MAX IMAGE SIZE: 16384 x 16384
MAX WORK GROUP SIZE: 1024
MAX WORK ITEM DIMENSIONS: 3
MAX WORK ITEM SIZES: [ 1024 1024 64 ]
ASYNC PIXELPIPE: NO
PINNED MEMORY TRANSFER: NO
AVOID ATOMICS: NO
MICRO NAP: 250
ROUNDUP WIDTH & HEIGHT 16x16
CHECK EVENT HANDLES: 128
TILING ADVANTAGE: 0.000
DEFAULT DEVICE: NO
KERNEL BUILD DIRECTORY: /usr/share/darktable/kernels
KERNEL DIRECTORY: /home/anna/.cache/darktable/cached_v3_kernels_for_rusticlNV168_2404arch12
CL COMPILER OPTION:
CL COMPILER COMMAND: -w -DNVIDIA_SM_20=1 -DNVIDIA=1 -I"/usr/share/darktable/kernels"
/usr/include/c++/13.2.1/bits/stl_deque.h:1385: std::deque<_Tp, _Alloc>::const_reference std::deque<_Tp, _Alloc>::operator[](size_type) const [with _Tp = nv50_ir::ValueDef; _Alloc = std::allocator<nv50_ir::ValueDef>; const_reference = const nv50_ir::ValueDef&; size_type = long unsigned int]: Assertion '__n < this->size()' failed.
Aborted (core dumped)
The error you get is an out-of-bounds error in a C++ data structure (but not in the mentioned header file, it just shows up there).
When I run darktable-cltest for my system (NVidia GTX 1060 with Nvidia binary drivers ver. 470.239.06), I get virtually the same output, with two differences:
gcc --version gives “gcc (SUSE Linux) 12.3.0”, which is also the version used to compile darktable-cltest. This GCC version uses C++17 by default. But for a long time, it used to be version 7, where darktable needed version 12 or better.
Well, if it’s any help. This is the output on Ubuntu 23.10:
anna@anna-ms7c96:~$ darktable-cltest
0,0143 [dt_get_sysresource_level] switched to 1 as `default'
0,0143 total mem: 15903MB
0,0143 mipmap cache: 1987MB
0,0143 available mem: 7951MB
0,0143 singlebuff: 124MB
0,0143 OpenCL tune mem: OFF
0,0143 OpenCL pinned: OFF
[opencl_init] opencl related configuration options:
[opencl_init] opencl: ON
[opencl_init] opencl_scheduling_profile: 'default'
[opencl_init] opencl_library: 'default path'
[opencl_init] opencl_device_priority: '*/!0,*/*/*/!0,*'
[opencl_init] opencl_mandatory_timeout: 400
0.0168 [dt_dlopencl_init] could not find default opencl runtime library 'libOpenCL'
0.0169 [dt_dlopencl_init] could not find default opencl runtime library 'libOpenCL.so'
[opencl_init] opencl library 'libOpenCL.so.1' found on your system and loaded
[opencl_init] found 2 platforms
[opencl_init] no devices found for Mesa (vendor) - Clover (name)
[opencl_init] found 1 device
[dt_opencl_device_init]
DEVICE: 0: 'NV168', NEW
PLATFORM NAME & VENDOR: rusticl, Mesa/X.org
CANONICAL NAME: rusticlnv168
DRIVER VERSION: 23.2.1-1ubuntu3.1
DEVICE VERSION: OpenCL 3.0 , SM_20 SUPPORT
DEVICE_TYPE: GPU
GLOBAL MEM SIZE: 6134 MB
MAX MEM ALLOC: 2048 MB
MAX IMAGE SIZE: 16384 x 16384
MAX WORK GROUP SIZE: 1024
MAX WORK ITEM DIMENSIONS: 3
MAX WORK ITEM SIZES: [ 1024 1024 64 ]
ASYNC PIXELPIPE: NO
PINNED MEMORY TRANSFER: NO
MEMORY TUNING: NO
FORCED HEADROOM: 400
AVOID ATOMICS: NO
MICRO NAP: 250
ROUNDUP WIDTH: 16
ROUNDUP HEIGHT: 16
CHECK EVENT HANDLES: 128
TILING ADVANTAGE: 0.000
DEFAULT DEVICE: NO
KERNEL BUILD DIRECTORY: /usr/share/darktable/kernels
KERNEL DIRECTORY: /home/anna/.cache/darktable/cached_v1_kernels_for_rusticlNV168_23211ubuntu31
CL COMPILER OPTION: -cl-fast-relaxed-math
1.5749 [opencl_build_program] could not build program: CL_BUILD_PROGRAM_FAILURE
1.5749 [dt_opencl_device_init] failed to compile program `bilateral.cl'!
[opencl_init] no suitable devices found.
[opencl_init] FINALLY: opencl is NOT AVAILABLE and NOT ENABLED.
I think I was fooled by that compiler option to think gcc (or clang) were involved.
A bit more reading makes me believe that the actual kernel compiler is part of the openCL driver package you use (mesa/rusticl). If that’s the case, it may be that the rusticl compiler isn’t compatible with darktable’s kernels.
Unfortunately, I’ve no idea how to figure that out.
Another issue may be the nouveau driver. My distribution (OpenSUSe) still has the graphics acceleration part of nouveau marked as experimental. And while there’s a lot of progress being maed (apparently), the nouveau driver is still not recommended for programs like blender (although blender seems to prefer CUDA over openCL)
Well I think amd people are using it since some time, so I think it’s actually in production, and as far as I know nouveau support was there before radeonsi.
Edit: but it’s true there are practically no resources for making rusticl work with nouveau but my guess is that nobody is really interested yet because the proprietary driver is better/faster. Not even hard core open source people, but those don’t buy an Nvidia GPU in the first place.
Well, as I found out on github with the help of @Jens-Hanno_Schwalm and Karol Herbst, it is already possible to run darktable opencl without the proprietary Nvidia driver, but it’s quite buggy. But it should be more usable by the end of may when mesa 24.1 is out.
The trick is not choosing the nouveau rusticl driver, but instead setting RUSTICL_ENABLE=zink. And the new NVK driver needs to be installed as well. So darktable actually uses Vulkan for GPU acceleration.
Speed is in about the same as with the proprietary Nvidia driver, but several important modules make darktable crash, e.g. color balance rgb. And very often the preview is completely wrong like black.