This repository contains a specialized build script, build_darktable.sh, designed to automate the process of updating the darktable source code and building it with a specific, pre-configured set of features and installation parameters.
The build_darktable.sh script is a wrapper around the official darktable build.sh script. Its primary goal is to:
- Ensure consistency: It uses a predefined set of build options (like
--enable-aiand--prefix /opt/darktable) so that every build is reproducible and contains the required features. - Automate updates: It automatically performs a
git pull --recurse-submodulesto ensure the build is always based on the latest available source code and submodules. - Guaranteed clean builds: It automatically removes any existing build directory to prevent conflicts between previous builds and the current one.
- Simplify the workflow: Instead of remembering complex build flags or running multiple commands (pull, then build, then install), a single command handles the entire lifecycle.
Before running the script, ensure you have the following:
- Darktable Source: The
darktable/directory must exist in the same folder as the script. - Dependencies: The system must have all the necessary dependencies for building darktable (as required by the darktable
build.shscript). - Permissions: Since the script uses the
--sudoflag during installation, you must have sudo privileges on the system.
To build and install darktable, simply execute the script from the root of this repository:
chmod +x build_darktable.sh
./build_darktable.shThe build configuration is defined within the BUILD_OPTIONS array inside build_darktable.sh. You can modify this array to change the installation prefix, build type, or enabled features. To see the available options:
darktable/build.sh --helpCurrent default options:
--prefix /opt/darktable--build-type Release--enable-ai--install--sudo
The options above includes the enable-ai flag which is required to use the new ai denoising, mask generation and upscaling features.
Works out-of-the-box after installing and using the darktable provided onnxruntime. Also works with a self compiled onnxruntime, see beloe.
On Fedora44 the ROCm libraries are not stored under /opt/rocm but under /usr/lib64/rocm. Also when using the latest onnxruntime from MS and the ROCm 7.1.1 libraries I find the darktable src code must be patched to fix this hardcoded path, see my_changes.patch.
If the ROCm, hip and migraphix libraries in Fedora44 repository are installed, onnxruntime can be compiled to use migraphx. (Refer https://github.com/stoflom/onnxruntime). The compiled onnxruntime can then be selected in the preferences->ai submenu.
With onnxruntime and the migraphx execution provider on my AMD Ryzen Pro 9 8945HS ai is sped up about 10 times. However, initially compiling the onnx kernels take a very long time > 40min for the raw denoise. The kernels are compiled when first used a process which makes darktable appear to be frozen. It is better to run darktable from the commandline to initially compile the migraphix kernels so that progress can be monitored.
darktable -d aiSaving the compiled kernels in a cache is essential for future use (see setenv.sh).
#Set migraphx cache directory
export ORT_MIGRAPHX_MODEL_CACHE_PATH='/home/stoflom/.cache/darktable/ai/amd/migraphx'
# Allow migraphx to compile with all cpu's'
export MIGRAPHX_GPU_COMPILE_PARALLEL=16When all goes well the kernels (mxr files) will be created under /home/s/.cache/darktable/ai/amd/migraphx